Skip to content

Commit 1fb60ab

Browse files
authored
docs(v3): update API references to new Manager API pattern (#4863)
* docs(v3): update API references to new Manager API pattern Update documentation to reflect the Manager API refactoring from alpha.10: Window API: - app.NewWebviewWindow() -> app.Window.New() - app.NewWebviewWindowWithOptions() -> app.Window.NewWithOptions() - app.CurrentWindow() -> app.Window.Current() - app.GetAllWindows() -> app.Window.GetAll() - app.WindowByName() -> app.Window.GetByName() Event API: - app.EmitEvent() -> app.Event.Emit() - app.OnEvent() -> app.Event.On() - app.OnApplicationEvent() -> app.Event.OnApplicationEvent() Dialog API: - app.OpenFileDialog() -> app.Dialog.OpenFile() - app.SaveFileDialog() -> app.Dialog.SaveFile() - app.InfoDialog() -> app.Dialog.Info() - app.ErrorDialog() -> app.Dialog.Error() - app.WarningDialog() -> app.Dialog.Warning() - app.QuestionDialog() -> app.Dialog.Question() Other APIs: - app.NewSystemTray() -> app.SystemTray.New() - app.SetApplicationMenu() -> app.Menu.Set() - app.GetPrimaryScreen() -> app.Screen.GetPrimary() - app.GetAllScreens() -> app.Screen.GetAll() - app.ClipboardGetText() -> app.Clipboard.Text() - app.ClipboardSetText() -> app.Clipboard.SetText() - app.BrowserOpenURL() -> app.Browser.OpenURL() Fixes outdated code examples across 31 documentation files. * chore(v3): add docs fix to unreleased changelog
1 parent 862e2e8 commit 1fb60ab

32 files changed

+257
-256
lines changed

docs/src/content/docs/concepts/architecture.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Frontend2 -> EventBus: "On('data-updated', handler)"
264264
**Example:**
265265
```go
266266
// Go: Emit an event
267-
app.EmitEvent("user-logged-in", user)
267+
app.Event.Emit("user-logged-in", user)
268268
```
269269

270270
```javascript

docs/src/content/docs/concepts/bridge.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func ProcessLargeFile(path string) error {
538538
for scanner.Scan() {
539539
lineNum++
540540
// Emit progress events
541-
app.EmitEvent("file-progress", map[string]interface{}{
541+
app.Event.Emit("file-progress", map[string]interface{}{
542542
"line": lineNum,
543543
"text": scanner.Text(),
544544
})

docs/src/content/docs/concepts/build-system.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func main() {
325325
},
326326
})
327327

328-
app.NewWebviewWindow()
328+
app.Window.New()
329329
app.Run()
330330
}
331331
```

docs/src/content/docs/contributing/runtime-internals.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ win := app.Window.New(&application.WebviewWindowOptions{
3939
win.Show()
4040
```
4141

42-
`NewWebviewWindow` delegates to `internal/runtime/webview_window_*.go` where
42+
`app.Window.New()` delegates to `internal/runtime/webview_window_*.go` where
4343
platform-specific constructors live:
4444

4545
```

docs/src/content/docs/faq.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,16 @@ Use SignTool with your certificate.
123123
Yes! Wails v3 has native multi-window support:
124124

125125
```go
126-
window1 := app.NewWebviewWindow()
127-
window2 := app.NewWebviewWindow()
126+
window1 := app.Window.New()
127+
window2 := app.Window.New()
128128
```
129129

130130
### Does Wails support system tray?
131131

132132
Yes! Create system tray applications:
133133

134134
```go
135-
tray := app.NewSystemTray()
135+
tray := app.SystemTray.New()
136136
tray.SetIcon(iconBytes)
137137
tray.SetMenu(menu)
138138
```
@@ -142,7 +142,7 @@ tray.SetMenu(menu)
142142
Yes! Wails provides native dialogs:
143143

144144
```go
145-
path, _ := app.OpenFileDialog().
145+
path, _ := app.Dialog.OpenFile().
146146
SetTitle("Select File").
147147
PromptForSingleSelection()
148148
```
@@ -194,7 +194,7 @@ wails3 generate bindings
194194
Check if you called `Show()`:
195195

196196
```go
197-
window := app.NewWebviewWindow()
197+
window := app.Window.New()
198198
window.Show() // Don't forget this!
199199
```
200200

@@ -204,7 +204,7 @@ Ensure event names match exactly:
204204

205205
```go
206206
// Go
207-
app.EmitEvent("my-event", data)
207+
app.Event.Emit("my-event", data)
208208

209209
// JavaScript
210210
OnEvent("my-event", handler) // Must match

docs/src/content/docs/features/bindings/best-practices.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (s *Service) ProcessLargeFile(path string) error {
274274
processed++
275275

276276
// Emit progress
277-
s.app.EmitEvent("progress", map[string]interface{}{
277+
s.app.Event.Emit("progress", map[string]interface{}{
278278
"processed": processed,
279279
"total": total,
280280
"percent": int(float64(processed) / float64(total) * 100),

docs/src/content/docs/features/bindings/methods.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ const config = await GetConfig()
461461
func ProcessLargeFile(path string) error {
462462
// Emit progress events
463463
for line := range lines {
464-
app.EmitEvent("progress", line)
464+
app.Event.Emit("progress", line)
465465
}
466466
return nil
467467
}
@@ -530,7 +530,7 @@ func main() {
530530
},
531531
})
532532

533-
app.NewWebviewWindow()
533+
app.Window.New()
534534
app.Run()
535535
}
536536
```

docs/src/content/docs/features/bindings/models.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ func main() {
628628
},
629629
})
630630

631-
app.NewWebviewWindow()
631+
app.Window.New()
632632
app.Run()
633633
}
634634
```

docs/src/content/docs/features/bindings/services.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ func (o *OrderService) CreateOrder(items []Item) (*Order, error) {
438438
}
439439

440440
// Emit event
441-
o.app.EmitEvent("order-created", order)
441+
o.app.Event.Emit("order-created", order)
442442

443443
return order, nil
444444
}
@@ -485,7 +485,7 @@ func NewNotificationService(app *application.Application) *NotificationService {
485485

486486
func (n *NotificationService) Notify(message string) {
487487
// Use application to emit events
488-
n.app.EmitEvent("notification", message)
488+
n.app.Event.Emit("notification", message)
489489

490490
// Or show system notification
491491
n.app.ShowNotification(message)
@@ -780,7 +780,7 @@ func main() {
780780
},
781781
})
782782

783-
app.NewWebviewWindow()
783+
app.Window.New()
784784
app.Run()
785785
}
786786
```

docs/src/content/docs/features/clipboard/basics.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ await CopyToClipboard("Text to copy")
6464
```go
6565
func copyWithFeedback(text string) {
6666
if app.Clipboard.SetText(text) {
67-
app.InfoDialog().
67+
app.Dialog.Info().
6868
SetTitle("Copied").
6969
SetMessage("Text copied to clipboard!").
7070
Show()
7171
} else {
72-
app.ErrorDialog().
72+
app.Dialog.Error().
7373
SetTitle("Copy Failed").
7474
SetMessage("Failed to copy to clipboard.").
7575
Show()
@@ -296,7 +296,7 @@ func (cm *ClipboardMonitor) checkClipboard() {
296296

297297
if text != cm.lastText {
298298
cm.lastText = text
299-
cm.app.EmitEvent("clipboard-changed", text)
299+
cm.app.Event.Emit("clipboard-changed", text)
300300
}
301301
}
302302
```

0 commit comments

Comments
 (0)