docs: fix issues from PR review comments

- menus.mdx: add Update() call after adding items to context menu snippet
- application.mdx: fix Emit() signature — remove fabricated bool return
- events-reference.mdx: fix files-dropped JS example to account for
  variadic wrapping (event.data[0] is the files array)
- bridge.mdx: fix progress event example — use variadic args directly
  and destructure event.data array in JS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lea Anthony 2026-02-09 21:41:54 +11:00
commit 6fcf2d6210
4 changed files with 15 additions and 9 deletions

View file

@ -538,10 +538,7 @@ func ProcessLargeFile(path string) error {
for scanner.Scan() {
lineNum++
// Emit progress events
app.Event.Emit("file-progress", map[string]interface{}{
"line": lineNum,
"text": scanner.Text(),
})
app.Event.Emit("file-progress", lineNum, scanner.Text())
}
return scanner.Err()
@ -553,8 +550,10 @@ import { Events } from '@wailsio/runtime'
import { ProcessLargeFile } from './bindings/FileService'
// Listen for progress
// event.data is an array of the variadic args: [lineNum, text]
Events.On('file-progress', (event) => {
console.log(`Line ${event.data.line}: ${event.data.text}`)
const [line, text] = event.data
console.log(`Line ${line}: ${text}`)
})
// Start processing

View file

@ -214,7 +214,10 @@ Then listen in JavaScript:
import { Events } from '@wailsio/runtime';
Events.On('files-dropped', (event) => {
event.data.forEach(file => {
// EmitEvent is variadic, so event.data is a []any wrapping the args.
// The files array is the first element.
const files = event.data[0];
files.forEach(file => {
console.log('File dropped:', file);
handleFileUpload(file);
});

View file

@ -436,6 +436,12 @@ When creating a custom context menu, you provide a unique identifier (name) that
```go
// Create a context menu with identifier "imageMenu"
contextMenu := application.NewContextMenu("imageMenu")
// Add items and call Update() to apply changes
contextMenu.Add("Cut")
contextMenu.Add("Copy")
contextMenu.Add("Paste")
contextMenu.Update()
```
The name parameter ("imageMenu" in this example) serves as a unique identifier that will be used to:

View file

@ -347,11 +347,9 @@ app.RegisterService(application.NewService(&MyService{}))
Emits a custom event.
```go
func (em *EventManager) Emit(name string, data ...any) bool
func (em *EventManager) Emit(name string, data ...any)
```
**Returns:** `true` if the event was cancelled by a hook.
**Example:**
```go