Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions docs/src/content/docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking Changes

- **Manager API Refactoring**: Reorganized application API from flat structure to organized managers for better code organization and discoverability by [@leaanthony](https://github.com/leaanthony) in [#4359](https://github.com/wailsapp/wails/pull/4359)
- `app.NewWebviewWindow()` → `app.Windows.New()`
- `app.CurrentWindow()` → `app.Windows.Current()`
- `app.GetAllWindows()` → `app.Windows.GetAll()`
- `app.WindowByName()` → `app.Windows.GetByName()`
- `app.EmitEvent()` → `app.Events.Emit()`
- `app.OnApplicationEvent()` → `app.Events.OnApplicationEvent()`
- `app.OnWindowEvent()` → `app.Events.OnWindowEvent()`
- `app.SetApplicationMenu()` → `app.Menus.SetApplicationMenu()`
- `app.OpenFileDialog()` → `app.Dialogs.OpenFile()`
- `app.SaveFileDialog()` → `app.Dialogs.SaveFile()`
- `app.MessageDialog()` → `app.Dialogs.Message()`
- `app.InfoDialog()` → `app.Dialogs.Info()`
- `app.WarningDialog()` → `app.Dialogs.Warning()`
- `app.ErrorDialog()` → `app.Dialogs.Error()`
- `app.QuestionDialog()` → `app.Dialogs.Question()`
- `app.NewWebviewWindow()` → `app.Window.New()`
- `app.CurrentWindow()` → `app.Window.Current()`
- `app.GetAllWindows()` → `app.Window.GetAll()`
- `app.WindowByName()` → `app.Window.GetByName()`
- `app.EmitEvent()` → `app.Event.Emit()`
- `app.OnApplicationEvent()` → `app.Event.OnApplicationEvent()`
- `app.OnWindowEvent()` → `app.Event.OnWindowEvent()`
- `app.SetApplicationMenu()` → `app.Menu.SetApplicationMenu()`
- `app.OpenFileDialog()` → `app.Dialog.OpenFile()`
- `app.SaveFileDialog()` → `app.Dialog.SaveFile()`
- `app.MessageDialog()` → `app.Dialog.Message()`
- `app.InfoDialog()` → `app.Dialog.Info()`
- `app.WarningDialog()` → `app.Dialog.Warning()`
- `app.ErrorDialog()` → `app.Dialog.Error()`
- `app.QuestionDialog()` → `app.Dialog.Question()`
- `app.NewSystemTray()` → `app.SystemTray.New()`
- `app.GetSystemTray()` → `app.SystemTray.Get()`
- `app.ShowContextMenu()` → `app.ContextMenus.Show()`
- `app.RegisterKeybinding()` → `app.KeyBindings.Register()`
- `app.UnregisterKeybinding()` → `app.KeyBindings.Unregister()`
- `app.GetPrimaryScreen()` → `app.Screens.GetPrimary()`
- `app.GetAllScreens()` → `app.Screens.GetAll()`
- `app.ShowContextMenu()` → `app.ContextMenu.Show()`
- `app.RegisterKeybinding()` → `app.KeyBinding.Register()`
- `app.UnregisterKeybinding()` → `app.KeyBinding.Unregister()`
- `app.GetPrimaryScreen()` → `app.Screen.GetPrimary()`
- `app.GetAllScreens()` → `app.Screen.GetAll()`
- `app.BrowserOpenURL()` → `app.Browser.OpenURL()`
- `app.Environment()` → `app.Env.GetAll()`
- `app.ClipboardGetText()` → `app.Clipboard.Text()`
Expand Down
20 changes: 10 additions & 10 deletions docs/src/content/docs/learn/application-menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Application menus provide the main menu bar interface for your application. They

## Creating an Application Menu

Create a new application menu using the `New` method from the Menus manager:
Create a new application menu using the `New` method from the Menu manager:

```go
menu := app.Menus.New()
menu := app.Menu.New()
```

## Setting the Menu
Expand All @@ -23,10 +23,10 @@ The way to set the menu varies on the platform:
<Tabs>
<TabItem label="macOS" icon="fa-brands:apple">

On macOS, there is only one menu bar per application. Set the menu using the `Set` method of the Menus manager:
On macOS, there is only one menu bar per application. Set the menu using the `Set` method of the Menu manager:

```go
app.Menus.Set(menu)
app.Menu.Set(menu)
```

</TabItem>
Expand All @@ -36,7 +36,7 @@ The way to set the menu varies on the platform:
On Windows, there is a menu bar per window. Set the menu using the `SetMenu` method of the window:

```go
app.Windows.Current().SetMenu(menu)
app.Window.Current().SetMenu(menu)
```

</TabItem>
Expand All @@ -46,7 +46,7 @@ The way to set the menu varies on the platform:
On Linux, the menu bar is typically per window. Set the menu using the `SetMenu` method of the window:

```go
app.Windows.Current().SetMenu(menu)
app.Window.Current().SetMenu(menu)
```

</TabItem>
Expand Down Expand Up @@ -107,7 +107,7 @@ Menu items can control the application windows:
```go
viewMenu := menu.AddSubmenu("View")
viewMenu.Add("Toggle Fullscreen").OnClick(func(ctx *application.Context) {
window := app.Windows.Current()
window := app.Window.Current()
if window.Fullscreen() {
window.SetFullscreen(false)
} else {
Expand Down Expand Up @@ -190,7 +190,7 @@ Always test menu functionality across all target platforms to ensure consistent
:::

:::tip[Pro Tip]
Consider using the `app.Windows.Current()` method in menu handlers to affect the active window, rather than storing window references.
Consider using the `app.Window.Current()` method in menu handlers to affect the active window, rather than storing window references.
:::

## Complete Example
Expand All @@ -211,7 +211,7 @@ func main() {
})

// Create main menu
menu := app.Menus.New()
menu := app.Menu.New()

// Add platform-specific application menu
if runtime.GOOS == "darwin" {
Expand Down Expand Up @@ -245,7 +245,7 @@ func main() {
})

// Set the menu
app.Menus.Set(menu)
app.Menu.Set(menu)

// Create main window
app.NewWebviewWindow()
Expand Down
24 changes: 12 additions & 12 deletions docs/src/content/docs/learn/browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ Provide easy access to help resources:
```go
// Create help menu
func setupHelpMenu(app *application.App) {
menu := app.Menus.New()
menu := app.Menu.New()
helpMenu := menu.AddSubmenu("Help")

helpMenu.Add("Online Documentation").OnClick(func(ctx *application.Context) {
err := app.Browser.OpenURL("https://docs.yourapp.com")
if err != nil {
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("Error").
SetMessage("Could not open documentation").
Show()
Expand Down Expand Up @@ -149,7 +149,7 @@ func handleExternalLink(app *application.App, url string) {
}

// Optionally confirm with user
dialog := app.Dialogs.Question()
dialog := app.Dialog.Question()
dialog.SetTitle("Open External Link")
dialog.SetMessage(fmt.Sprintf("Open %s in your browser?", url))

Expand Down Expand Up @@ -244,12 +244,12 @@ func setupDevelopmentMenu(app *application.App) {
return // Only show in debug mode
}

menu := app.Menus.New()
menu := app.Menu.New()
devMenu := menu.AddSubmenu("Development")

devMenu.Add("Open DevTools").OnClick(func(ctx *application.Context) {
// This would open browser devtools if available
window := app.Windows.Current()
window := app.Window.Current()
if window != nil {
window.OpenDevTools()
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func openURLWithFallback(app *application.App, url string, fallbackMessage strin
app.Logger.Error("Failed to open URL", "url", url, "error", err)

// Show fallback dialog with URL
dialog := app.Dialogs.Info()
dialog := app.Dialog.Info()
dialog.SetTitle("Unable to Open Link")
dialog.SetMessage(fmt.Sprintf("%s\n\nURL: %s", fallbackMessage, url))
dialog.Show()
Expand All @@ -302,7 +302,7 @@ func openURLWithFeedback(app *application.App, url string) {
err := app.Browser.OpenURL(url)
if err != nil {
// Show error dialog
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("Browser Error").
SetMessage(fmt.Sprintf("Could not open URL: %s", err.Error())).
Show()
Expand Down Expand Up @@ -408,7 +408,7 @@ func main() {
setupMenu(app)

// Create main window
window := app.Windows.New()
window := app.Window.New()
window.SetTitle("Browser Integration")

err := app.Run()
Expand All @@ -418,7 +418,7 @@ func main() {
}

func setupMenu(app *application.App) {
menu := app.Menus.New()
menu := app.Menu.New()

// File menu
fileMenu := menu.AddSubmenu("File")
Expand All @@ -435,11 +435,11 @@ func setupMenu(app *application.App) {
openWithConfirmation(app, "https://support.example.com")
})

app.Menus.Set(menu)
app.Menu.Set(menu)
}

func openWithConfirmation(app *application.App, url string) {
dialog := app.Dialogs.Question()
dialog := app.Dialog.Question()
dialog.SetTitle("Open External Link")
dialog.SetMessage(fmt.Sprintf("Open %s in your browser?", url))

Expand Down Expand Up @@ -494,7 +494,7 @@ func generateHTMLReport(app *application.App) {
}

func showError(app *application.App, message string, err error) {
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("Error").
SetMessage(fmt.Sprintf("%s: %v", message, err)).
Show()
Expand Down
14 changes: 7 additions & 7 deletions docs/src/content/docs/learn/clipboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
})

// Create a custom menu
menu := app.Menus.New()
menu := app.Menu.New()
if runtime.GOOS == "darwin" {
menu.AddRole(application.AppMenu)
}
Expand All @@ -85,31 +85,31 @@ func main() {
setClipboardMenu.Add("Set Text 'Hello'").OnClick(func(ctx *application.Context) {
success := app.Clipboard.SetText("Hello")
if !success {
app.Dialogs.Info().SetMessage("Failed to set clipboard text").Show()
app.Dialog.Info().SetMessage("Failed to set clipboard text").Show()
}
})

getClipboardMenu := menu.AddSubmenu("Get Clipboard")
getClipboardMenu.Add("Get Text").OnClick(func(ctx *application.Context) {
result, ok := app.Clipboard.Text()
if !ok {
app.Dialogs.Info().SetMessage("Failed to get clipboard text").Show()
app.Dialog.Info().SetMessage("Failed to get clipboard text").Show()
} else {
app.Dialogs.Info().SetMessage("Got:\n\n" + result).Show()
app.Dialog.Info().SetMessage("Got:\n\n" + result).Show()
}
})

clearClipboardMenu := menu.AddSubmenu("Clear Clipboard")
clearClipboardMenu.Add("Clear Text").OnClick(func(ctx *application.Context) {
success := app.Clipboard.SetText("")
if success {
app.Dialogs.Info().SetMessage("Clipboard text cleared").Show()
app.Dialog.Info().SetMessage("Clipboard text cleared").Show()
} else {
app.Dialogs.Info().SetMessage("Clipboard text not cleared").Show()
app.Dialog.Info().SetMessage("Clipboard text not cleared").Show()
}
})

app.Menus.Set(menu)
app.Menu.Set(menu)
app.NewWebviewWindow()

err := app.Run()
Expand Down
16 changes: 8 additions & 8 deletions docs/src/content/docs/learn/context-menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Context menus are popup menus that appear when right-clicking elements in your a

## Creating a Context Menu

To create a context menu, use the `Add` method from the ContextMenus manager:
To create a context menu, use the `Add` method from the ContextMenu manager:

```go
contextMenu := app.ContextMenus.Add("menu-id", application.NewContextMenu())
contextMenu := app.ContextMenu.Add("menu-id", application.NewContextMenu())
```

The `menu-id` parameter is a unique identifier for the menu that will be used to associate it with HTML elements.
Expand All @@ -35,7 +35,7 @@ contextMenu.Add("Paste").OnClick(func(ctx *application.Context) {
})

// Register the context menu with the manager
app.ContextMenus.Add("editor-menu", contextMenu)
app.ContextMenu.Add("editor-menu", contextMenu)
```

:::tip[Menu Items]
Expand All @@ -47,15 +47,15 @@ For detailed information about available menu item types and properties, refer t
Context menus can receive data from the HTML element that triggered them. This data can be accessed in the click handlers:

```go
contextMenu := app.ContextMenus.New()
contextMenu := app.ContextMenu.New()
menuItem := contextMenu.Add("Process Image")
menuItem.OnClick(func(ctx *application.Context) {
imageID := ctx.ContextMenuData()
// Process the image using the ID
})

// Register the context menu with the manager
app.ContextMenus.Add("image-menu", contextMenu)
app.ContextMenu.Add("image-menu", contextMenu)
```

## Associating with HTML Elements
Expand Down Expand Up @@ -113,7 +113,7 @@ contextMenu := application.NewContextMenu()
menuItem := contextMenu.Add("Initial Label")

// Register the context menu with the manager
app.ContextMenus.Add("dynamic-menu", contextMenu)
app.ContextMenu.Add("dynamic-menu", contextMenu)

// Later, update the menu item
menuItem.SetLabel("New Label")
Expand Down Expand Up @@ -195,7 +195,7 @@ func main() {
})

// Create a context menu
contextMenu := app.ContextMenus.New()
contextMenu := app.ContextMenu.New()

// Add items that respond to context data
clickMe := contextMenu.Add("Click to show context data")
Expand All @@ -208,7 +208,7 @@ func main() {
})

// Register the context menu with the manager
app.ContextMenus.Add("test", contextMenu)
app.ContextMenu.Add("test", contextMenu)

window := app.NewWebviewWindow()
window.SetTitle("Context Menu Demo")
Expand Down
Loading