Refactor Manager API to use singular naming convention (#4367)

* Refactor Manager API to use singular naming convention

This is a RENAME-ONLY exercise that converts the Wails v3 Manager API from plural to singular naming for better consistency and clarity.

## Changes Applied

### API Transformations:
- `app.Windows.*` → `app.Window.*`
- `app.Events.*` → `app.Event.*`
- `app.ContextMenus.*` → `app.ContextMenu.*`
- `app.KeyBindings.*` → `app.KeyBinding.*`
- `app.Dialogs.*` → `app.Dialog.*`
- `app.Menus.*` → `app.Menu.*`
- `app.Screens.*` → `app.Screen.*`

### Files Updated:
- **Core Application**: 22 files in `v3/pkg/application/`
- **Examples**: 43+ files in `v3/examples/`
- **Documentation**: 13 files in `docs/src/content/docs/`
- **CLI Tests**: 1 file in `v3/internal/commands/`

### Critical Constraints Preserved:
-  Event string constants unchanged (e.g., "windows:WindowShow")
-  Platform event names preserved (events.Windows, events.Mac, etc.)
-  TypeScript API remains compatible
-  All functionality intact

### Verification:
-  All examples build successfully (`task test:examples` passes)
-  Application package compiles without errors
-  Documentation reflects new API patterns

## Benefits

- **Improved Clarity**: Singular names are more intuitive (`app.Window` vs `app.Windows`)
- **Better Consistency**: Aligns with Go naming conventions
- **Enhanced Developer Experience**: Clearer autocomplete and API discovery

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix generator testcases and add cross-platform test cleanup

- Update 28 generator testcase files to use singular API (app.Window.New() vs app.Windows.New())
- Add cross-platform cleanup system with Go script to remove test artifacts
- Add test:all task with comprehensive testing and automatic cleanup
- Fix cleanup to target files vs directories correctly (preserves source directories)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix remaining Windows CI failures by updating all plural API usage to singular

Fixed the last remaining instances of old plural Manager API usage:
- tests/window-visibility-test/main.go: Updated all app.Windows -> app.Window and app.Menus -> app.Menu
- internal/templates/_common/main.go.tmpl: Updated app.Windows -> app.Window and app.Events -> app.Event
- pkg/services/badge/badge_windows.go: Updated app.Windows -> app.Window (Windows-specific fix)

These fixes address the Windows CI failures where platform-specific files still used the old API.
The tests didn't catch this locally because Windows-specific files only compile on Windows.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Lea Anthony 2025-06-22 12:19:14 +10:00 committed by GitHub
commit 3087ba0bdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
123 changed files with 686 additions and 565 deletions

View file

@ -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()`

View file

@ -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
@ -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>
@ -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>
@ -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>
@ -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 {
@ -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
@ -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" {
@ -245,7 +245,7 @@ func main() {
})
// Set the menu
app.Menus.Set(menu)
app.Menu.Set(menu)
// Create main window
app.NewWebviewWindow()

View file

@ -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()
@ -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))
@ -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()
}
@ -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()
@ -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()
@ -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()
@ -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")
@ -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))
@ -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()

View file

@ -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)
}
@ -85,7 +85,7 @@ 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()
}
})
@ -93,9 +93,9 @@ func main() {
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()
}
})
@ -103,13 +103,13 @@ func main() {
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()

View file

@ -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.
@ -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]
@ -47,7 +47,7 @@ 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()
@ -55,7 +55,7 @@ menuItem.OnClick(func(ctx *application.Context) {
})
// Register the context menu with the manager
app.ContextMenus.Add("image-menu", contextMenu)
app.ContextMenu.Add("image-menu", contextMenu)
```
## Associating with HTML Elements
@ -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")
@ -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")
@ -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")

View file

@ -15,7 +15,7 @@ Wails provides a comprehensive dialog system for displaying native system dialog
Display simple informational messages to users:
```go
dialog := app.Dialogs.Info()
dialog := app.Dialog.Info()
dialog.SetTitle("Welcome")
dialog.SetMessage("Welcome to our application!")
dialog.Show()
@ -26,7 +26,7 @@ dialog.Show()
Present users with questions and customisable buttons:
```go
dialog := app.Dialogs.Question()
dialog := app.Dialog.Question()
dialog.SetTitle("Save Changes")
dialog.SetMessage("Do you want to save your changes?")
dialog.AddButton("Save").OnClick(func() {
@ -42,7 +42,7 @@ dialog.Show()
Display error messages:
```go
dialog := app.Dialogs.Error()
dialog := app.Dialog.Error()
dialog.SetTitle("Error")
dialog.SetMessage("Failed to save file")
dialog.Show()
@ -55,7 +55,7 @@ dialog.Show()
Allow users to select files to open:
```go
dialog := app.Dialogs.OpenFile()
dialog := app.Dialog.OpenFile()
dialog.SetTitle("Select Image")
dialog.SetFilters([]*application.FileFilter{
{
@ -80,7 +80,7 @@ if paths, err := dialog.PromptForMultipleSelection(); err == nil {
Allow users to choose where to save files:
```go
dialog := app.Dialogs.SaveFile()
dialog := app.Dialog.SaveFile()
dialog.SetTitle("Save Document")
dialog.SetDefaultFilename("document.txt")
dialog.SetFilters([]*application.FileFilter{
@ -102,7 +102,7 @@ if path, err := dialog.PromptForSingleSelection(); err == nil {
Dialogs can use custom icons from the built-in icon set:
```go
dialog := app.Dialogs.Info()
dialog := app.Dialog.Info()
dialog.SetIcon(icons.ApplicationDarkMode256)
```
@ -111,8 +111,8 @@ dialog.SetIcon(icons.ApplicationDarkMode256)
Dialogs can be attached to specific windows:
```go
dialog := app.Dialogs.Question()
dialog.AttachToWindow(app.Windows.Current())
dialog := app.Dialog.Question()
dialog.AttachToWindow(app.Window.Current())
dialog.Show()
```
@ -121,7 +121,7 @@ dialog.Show()
Create buttons with custom labels and actions:
```go
dialog := app.Dialogs.Question()
dialog := app.Dialog.Question()
dialog.SetMessage("Choose an action")
// Add buttons with custom handlers
@ -183,7 +183,7 @@ dialog.SetDefaultButton(cancelButton) // Set default button
Allow users to select directories:
```go
dialog := app.Dialogs.OpenFile()
dialog := app.Dialog.OpenFile()
dialog.CanChooseDirectories(true)
dialog.CanChooseFiles(false)
dialog.SetTitle("Select Project Directory")
@ -197,7 +197,7 @@ if path, err := dialog.PromptForSingleSelection(); err == nil {
Display application information:
```go
app.Menus.ShowAbout()
app.Menu.ShowAbout()
```
## Best Practices

View file

@ -103,7 +103,7 @@ app.OnApplicationEvent(events.Common.ThemeChanged, func(event *application.Appli
func updateApplicationTheme(theme string) {
// Update your application's theme
// This could emit an event to the frontend
app.Events.Emit("theme:changed", theme)
app.Event.Emit("theme:changed", theme)
}
```
@ -142,7 +142,7 @@ func showInFileManager(app *application.App, path string) {
app.Logger.Error("Could not open file manager", "path", path, "error", err)
// Show error to user
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("File Manager Error").
SetMessage("Could not open file manager").
Show()
@ -152,7 +152,7 @@ func showInFileManager(app *application.App, path string) {
// Usage examples
func setupFileMenu(app *application.App) {
menu := app.Menus.New()
menu := app.Menu.New()
fileMenu := menu.AddSubmenu("File")
fileMenu.Add("Show Downloads Folder").OnClick(func(ctx *application.Context) {
@ -199,7 +199,7 @@ func configureMacOS(app *application.App) {
app.Logger.Info("Configuring for macOS")
// macOS-specific configuration
menu := app.Menus.New()
menu := app.Menu.New()
menu.AddRole(application.AppMenu) // Add standard macOS app menu
// Handle dark mode
@ -244,20 +244,20 @@ func setupApplicationMode(app *application.App) {
func setupDevelopmentFeatures(app *application.App) {
// Enable development-only features
menu := app.Menus.New()
menu := app.Menu.New()
// Add development menu
devMenu := menu.AddSubmenu("Development")
devMenu.Add("Reload Application").OnClick(func(ctx *application.Context) {
// Reload the application
window := app.Windows.Current()
window := app.Window.Current()
if window != nil {
window.Reload()
}
})
devMenu.Add("Open DevTools").OnClick(func(ctx *application.Context) {
window := app.Windows.Current()
window := app.Window.Current()
if window != nil {
window.OpenDevTools()
}
@ -309,7 +309,7 @@ Platform Information:`,
envInfo.OSInfo.Version)
}
dialog := app.Dialogs.Info()
dialog := app.Dialog.Info()
dialog.SetTitle("Environment Information")
dialog.SetMessage(details)
dialog.Show()
@ -456,7 +456,7 @@ func main() {
setupEnvironmentMenu(app)
// Create main window
window := app.Windows.New()
window := app.Window.New()
window.SetTitle("Environment Demo")
err := app.Run()
@ -509,7 +509,7 @@ func monitorThemeChanges(app *application.App) {
}
func setupEnvironmentMenu(app *application.App) {
menu := app.Menus.New()
menu := app.Menu.New()
// Add platform-specific app menu
if runtime.GOOS == "darwin" {
@ -533,7 +533,7 @@ func setupEnvironmentMenu(app *application.App) {
toggleTheme(app)
})
app.Menus.Set(menu)
app.Menu.Set(menu)
}
func showEnvironmentInfo(app *application.App) {
@ -562,7 +562,7 @@ Platform Details:`,
envInfo.OSInfo.Version)
}
dialog := app.Dialogs.Info()
dialog := app.Dialog.Info()
dialog.SetTitle("Environment Information")
dialog.SetMessage(message)
dialog.Show()
@ -580,7 +580,7 @@ func openDownloadsFolder(app *application.App) {
if err != nil {
app.Logger.Error("Could not open Downloads folder", "error", err)
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("File Manager Error").
SetMessage("Could not open Downloads folder").
Show()
@ -590,13 +590,13 @@ func openDownloadsFolder(app *application.App) {
func applyDarkTheme(app *application.App) {
app.Logger.Info("Applying dark theme")
// Emit theme change to frontend
app.Events.Emit("theme:apply", "dark")
app.Event.Emit("theme:apply", "dark")
}
func applyLightTheme(app *application.App) {
app.Logger.Info("Applying light theme")
// Emit theme change to frontend
app.Events.Emit("theme:apply", "light")
app.Event.Emit("theme:apply", "light")
}
func toggleTheme(app *application.App) {

View file

@ -431,8 +431,8 @@ You can emit custom events from anywhere in your application:
<Tabs>
<TabItem label="Manager API (Recommended)">
```go
// NEW: Using the Events Manager (recommended)
app.Events.Emit("myevent", "hello")
// NEW: Using the Event Manager (recommended)
app.Event.Emit("myevent", "hello")
// Emit from a specific window
window.EmitEvent("windowevent", "window specific data")
@ -456,8 +456,8 @@ Listen for custom events using the event management methods:
<Tabs>
<TabItem label="Manager API (Recommended)">
```go
// NEW: Using the Events Manager (recommended)
cancelFunc := app.Events.On("myevent", func(e *application.CustomEvent) {
// NEW: Using the Event Manager (recommended)
cancelFunc := app.Event.On("myevent", func(e *application.CustomEvent) {
// Access event information
name := e.Name // Event name
data := e.Data // Event data
@ -466,13 +466,13 @@ cancelFunc := app.Events.On("myevent", func(e *application.CustomEvent) {
})
// Remove specific event listener
app.Events.Off("myevent")
app.Event.Off("myevent")
// Remove all event listeners
app.Events.Reset()
app.Event.Reset()
// Listen for events a limited number of times
app.Events.OnMultiple("myevent", func(e *application.CustomEvent) {
app.Event.OnMultiple("myevent", func(e *application.CustomEvent) {
// This will only be called 3 times
}, 3)
```
@ -531,7 +531,7 @@ window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent
})
// For custom events
app.Events.On("myevent", func(e *application.CustomEvent) {
app.Event.On("myevent", func(e *application.CustomEvent) {
if e.IsCancelled() {
app.Logger.Info("Event was cancelled")
return

View file

@ -18,7 +18,7 @@ app := application.New(application.Options{
})
// Access the key binding manager
keyBindings := app.KeyBindings
keyBindings := app.KeyBinding
```
## Adding Key Bindings
@ -28,7 +28,7 @@ keyBindings := app.KeyBindings
Register a simple keyboard shortcut:
```go
app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+S", func(window *application.WebviewWindow) {
// Handle save action
app.Logger.Info("Save shortcut triggered")
// Perform save operation...
@ -41,36 +41,36 @@ Register multiple shortcuts for common operations:
```go
// File operations
app.KeyBindings.Add("Ctrl+N", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+N", func(window *application.WebviewWindow) {
// New file
window.EmitEvent("file:new", nil)
})
app.KeyBindings.Add("Ctrl+O", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+O", func(window *application.WebviewWindow) {
// Open file
dialog := app.Dialogs.OpenFile()
dialog := app.Dialog.OpenFile()
if file, err := dialog.PromptForSingleSelection(); err == nil {
window.EmitEvent("file:open", file)
}
})
app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+S", func(window *application.WebviewWindow) {
// Save file
window.EmitEvent("file:save", nil)
})
// Edit operations
app.KeyBindings.Add("Ctrl+Z", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+Z", func(window *application.WebviewWindow) {
// Undo
window.EmitEvent("edit:undo", nil)
})
app.KeyBindings.Add("Ctrl+Y", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+Y", func(window *application.WebviewWindow) {
// Redo (Windows/Linux)
window.EmitEvent("edit:redo", nil)
})
app.KeyBindings.Add("Cmd+Shift+Z", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Cmd+Shift+Z", func(window *application.WebviewWindow) {
// Redo (macOS)
window.EmitEvent("edit:redo", nil)
})
@ -117,14 +117,14 @@ import "runtime"
// Cross-platform save shortcut
if runtime.GOOS == "darwin" {
app.KeyBindings.Add("Cmd+S", saveHandler)
app.KeyBinding.Add("Cmd+S", saveHandler)
} else {
app.KeyBindings.Add("Ctrl+S", saveHandler)
app.KeyBinding.Add("Ctrl+S", saveHandler)
}
// Or register both
app.KeyBindings.Add("Ctrl+S", saveHandler)
app.KeyBindings.Add("Cmd+S", saveHandler)
app.KeyBinding.Add("Ctrl+S", saveHandler)
app.KeyBinding.Add("Cmd+S", saveHandler)
```
## Managing Key Bindings
@ -135,14 +135,14 @@ Remove key bindings when they're no longer needed:
```go
// Remove a specific key binding
app.KeyBindings.Remove("Ctrl+S")
app.KeyBinding.Remove("Ctrl+S")
// Example: Temporary key binding for a modal
app.KeyBindings.Add("Escape", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Escape", func(window *application.WebviewWindow) {
// Close modal
window.EmitEvent("modal:close", nil)
// Remove this temporary binding
app.KeyBindings.Remove("Escape")
app.KeyBinding.Remove("Escape")
})
```
@ -151,7 +151,7 @@ app.KeyBindings.Add("Escape", func(window *application.WebviewWindow) {
Retrieve all registered key bindings:
```go
allBindings := app.KeyBindings.GetAll()
allBindings := app.KeyBinding.GetAll()
for _, binding := range allBindings {
app.Logger.Info("Key binding", "accelerator", binding.Accelerator)
}
@ -164,7 +164,7 @@ for _, binding := range allBindings {
Make key bindings context-aware by checking application state:
```go
app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+S", func(window *application.WebviewWindow) {
// Check current application state
if isEditMode() {
// Save document
@ -183,7 +183,7 @@ app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
Key bindings receive the active window, allowing window-specific behavior:
```go
app.KeyBindings.Add("F11", func(window *application.WebviewWindow) {
app.KeyBinding.Add("F11", func(window *application.WebviewWindow) {
// Toggle fullscreen for the active window
if window.Fullscreen() {
window.SetFullscreen(false)
@ -192,7 +192,7 @@ app.KeyBindings.Add("F11", func(window *application.WebviewWindow) {
}
})
app.KeyBindings.Add("Ctrl+W", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+W", func(window *application.WebviewWindow) {
// Close the active window
window.Close()
})
@ -205,24 +205,24 @@ Dynamically add and remove key bindings based on application state:
```go
func enableEditMode() {
// Add edit-specific key bindings
app.KeyBindings.Add("Ctrl+B", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+B", func(window *application.WebviewWindow) {
window.EmitEvent("format:bold", nil)
})
app.KeyBindings.Add("Ctrl+I", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+I", func(window *application.WebviewWindow) {
window.EmitEvent("format:italic", nil)
})
app.KeyBindings.Add("Ctrl+U", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+U", func(window *application.WebviewWindow) {
window.EmitEvent("format:underline", nil)
})
}
func disableEditMode() {
// Remove edit-specific key bindings
app.KeyBindings.Remove("Ctrl+B")
app.KeyBindings.Remove("Ctrl+I")
app.KeyBindings.Remove("Ctrl+U")
app.KeyBinding.Remove("Ctrl+B")
app.KeyBinding.Remove("Ctrl+I")
app.KeyBinding.Remove("Ctrl+U")
}
```
@ -241,13 +241,13 @@ func disableEditMode() {
Common macOS patterns:
```go
app.KeyBindings.Add("Cmd+N", newFileHandler) // New
app.KeyBindings.Add("Cmd+O", openFileHandler) // Open
app.KeyBindings.Add("Cmd+S", saveFileHandler) // Save
app.KeyBindings.Add("Cmd+Z", undoHandler) // Undo
app.KeyBindings.Add("Cmd+Shift+Z", redoHandler) // Redo
app.KeyBindings.Add("Cmd+C", copyHandler) // Copy
app.KeyBindings.Add("Cmd+V", pasteHandler) // Paste
app.KeyBinding.Add("Cmd+N", newFileHandler) // New
app.KeyBinding.Add("Cmd+O", openFileHandler) // Open
app.KeyBinding.Add("Cmd+S", saveFileHandler) // Save
app.KeyBinding.Add("Cmd+Z", undoHandler) // Undo
app.KeyBinding.Add("Cmd+Shift+Z", redoHandler) // Redo
app.KeyBinding.Add("Cmd+C", copyHandler) // Copy
app.KeyBinding.Add("Cmd+V", pasteHandler) // Paste
```
</TabItem>
@ -263,14 +263,14 @@ func disableEditMode() {
Common Windows patterns:
```go
app.KeyBindings.Add("Ctrl+N", newFileHandler) // New
app.KeyBindings.Add("Ctrl+O", openFileHandler) // Open
app.KeyBindings.Add("Ctrl+S", saveFileHandler) // Save
app.KeyBindings.Add("Ctrl+Z", undoHandler) // Undo
app.KeyBindings.Add("Ctrl+Y", redoHandler) // Redo
app.KeyBindings.Add("Ctrl+C", copyHandler) // Copy
app.KeyBindings.Add("Ctrl+V", pasteHandler) // Paste
app.KeyBindings.Add("F1", helpHandler) // Help
app.KeyBinding.Add("Ctrl+N", newFileHandler) // New
app.KeyBinding.Add("Ctrl+O", openFileHandler) // Open
app.KeyBinding.Add("Ctrl+S", saveFileHandler) // Save
app.KeyBinding.Add("Ctrl+Z", undoHandler) // Undo
app.KeyBinding.Add("Ctrl+Y", redoHandler) // Redo
app.KeyBinding.Add("Ctrl+C", copyHandler) // Copy
app.KeyBinding.Add("Ctrl+V", pasteHandler) // Paste
app.KeyBinding.Add("F1", helpHandler) // Help
```
</TabItem>
@ -286,13 +286,13 @@ func disableEditMode() {
Common Linux patterns:
```go
app.KeyBindings.Add("Ctrl+N", newFileHandler) // New
app.KeyBindings.Add("Ctrl+O", openFileHandler) // Open
app.KeyBindings.Add("Ctrl+S", saveFileHandler) // Save
app.KeyBindings.Add("Ctrl+Z", undoHandler) // Undo
app.KeyBindings.Add("Ctrl+Shift+Z", redoHandler) // Redo
app.KeyBindings.Add("Ctrl+C", copyHandler) // Copy
app.KeyBindings.Add("Ctrl+V", pasteHandler) // Paste
app.KeyBinding.Add("Ctrl+N", newFileHandler) // New
app.KeyBinding.Add("Ctrl+O", openFileHandler) // Open
app.KeyBinding.Add("Ctrl+S", saveFileHandler) // Save
app.KeyBinding.Add("Ctrl+Z", undoHandler) // Undo
app.KeyBinding.Add("Ctrl+Shift+Z", redoHandler) // Redo
app.KeyBinding.Add("Ctrl+C", copyHandler) // Copy
app.KeyBinding.Add("Ctrl+V", pasteHandler) // Paste
```
</TabItem>
@ -304,15 +304,15 @@ func disableEditMode() {
```go
// Cross-platform save
if runtime.GOOS == "darwin" {
app.KeyBindings.Add("Cmd+S", saveHandler)
app.KeyBinding.Add("Cmd+S", saveHandler)
} else {
app.KeyBindings.Add("Ctrl+S", saveHandler)
app.KeyBinding.Add("Ctrl+S", saveHandler)
}
```
2. **Provide Visual Feedback**: Let users know when shortcuts are triggered:
```go
app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+S", func(window *application.WebviewWindow) {
saveDocument()
// Show brief notification
window.EmitEvent("notification:show", "Document saved")
@ -329,7 +329,7 @@ func disableEditMode() {
4. **Document Shortcuts**: Provide help or documentation for available shortcuts:
```go
app.KeyBindings.Add("F1", func(window *application.WebviewWindow) {
app.KeyBinding.Add("F1", func(window *application.WebviewWindow) {
// Show help dialog with available shortcuts
showKeyboardShortcutsHelp()
})
@ -338,12 +338,12 @@ func disableEditMode() {
5. **Clean Up**: Remove temporary key bindings when they're no longer needed:
```go
func enterEditMode() {
app.KeyBindings.Add("Escape", exitEditModeHandler)
app.KeyBinding.Add("Escape", exitEditModeHandler)
}
func exitEditModeHandler(window *application.WebviewWindow) {
exitEditMode()
app.KeyBindings.Remove("Escape") // Clean up temporary binding
app.KeyBinding.Remove("Escape") // Clean up temporary binding
}
```
@ -366,38 +366,38 @@ func main() {
// File operations
if runtime.GOOS == "darwin" {
app.KeyBindings.Add("Cmd+N", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Cmd+N", func(window *application.WebviewWindow) {
window.EmitEvent("file:new", nil)
})
app.KeyBindings.Add("Cmd+O", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Cmd+O", func(window *application.WebviewWindow) {
openFile(app, window)
})
app.KeyBindings.Add("Cmd+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Cmd+S", func(window *application.WebviewWindow) {
window.EmitEvent("file:save", nil)
})
} else {
app.KeyBindings.Add("Ctrl+N", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+N", func(window *application.WebviewWindow) {
window.EmitEvent("file:new", nil)
})
app.KeyBindings.Add("Ctrl+O", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+O", func(window *application.WebviewWindow) {
openFile(app, window)
})
app.KeyBindings.Add("Ctrl+S", func(window *application.WebviewWindow) {
app.KeyBinding.Add("Ctrl+S", func(window *application.WebviewWindow) {
window.EmitEvent("file:save", nil)
})
}
// View operations
app.KeyBindings.Add("F11", func(window *application.WebviewWindow) {
app.KeyBinding.Add("F11", func(window *application.WebviewWindow) {
window.SetFullscreen(!window.Fullscreen())
})
app.KeyBindings.Add("F1", func(window *application.WebviewWindow) {
app.KeyBinding.Add("F1", func(window *application.WebviewWindow) {
showKeyboardShortcuts(window)
})
// Create main window
window := app.Windows.New()
window := app.Window.New()
window.SetTitle("Text Editor")
err := app.Run()
@ -407,7 +407,7 @@ func main() {
}
func openFile(app *application.App, window *application.WebviewWindow) {
dialog := app.Dialogs.OpenFile()
dialog := app.Dialog.OpenFile()
dialog.AddFilter("Text Files", "*.txt;*.md")
if file, err := dialog.PromptForSingleSelection(); err == nil {

View file

@ -12,15 +12,15 @@ The Wails v3 Manager API provides an organized and discoverable way to access ap
The Manager API organizes application functionality into eleven focused areas:
- **`app.Windows`** - Window creation, management, and callbacks
- **`app.ContextMenus`** - Context menu registration and management
- **`app.KeyBindings`** - Global key binding management
- **`app.Window`** - Window creation, management, and callbacks
- **`app.ContextMenu`** - Context menu registration and management
- **`app.KeyBinding`** - Global key binding management
- **`app.Browser`** - Browser integration (opening URLs and files)
- **`app.Env`** - Environment information and system state
- **`app.Dialogs`** - File and message dialog operations
- **`app.Events`** - Custom event handling and application events
- **`app.Menus`** - Application menu management
- **`app.Screens`** - Screen management and coordinate transformations
- **`app.Dialog`** - File and message dialog operations
- **`app.Event`** - Custom event handling and application events
- **`app.Menu`** - Application menu management
- **`app.Screen`** - Screen management and coordinate transformations
- **`app.Clipboard`** - Clipboard text operations
- **`app.SystemTray`** - System tray icon creation and management
@ -37,19 +37,19 @@ The Manager API provides organized access to all application functionality:
```go
// Events and custom event handling
app.Events.Emit("custom", data)
app.Events.On("custom", func(e *CustomEvent) { ... })
app.Event.Emit("custom", data)
app.Event.On("custom", func(e *CustomEvent) { ... })
// Window management
window, _ := app.Windows.GetByName("main")
app.Windows.OnCreate(func(window Window) { ... })
window, _ := app.Window.GetByName("main")
app.Window.OnCreate(func(window Window) { ... })
// Browser integration
app.Browser.OpenURL("https://wails.io")
// Menu management
menu := app.Menus.New()
app.Menus.Set(menu)
menu := app.Menu.New()
app.Menu.Set(menu)
// System tray
systray := app.SystemTray.New()
@ -57,41 +57,41 @@ systray := app.SystemTray.New()
## Manager Reference
### Windows Manager
### Window Manager
Manages window creation, retrieval, and lifecycle callbacks.
```go
// Create windows
window := app.Windows.New()
window := app.Windows.NewWithOptions(options)
current := app.Windows.Current()
window := app.Window.New()
window := app.Window.NewWithOptions(options)
current := app.Window.Current()
// Find windows
window, exists := app.Windows.GetByName("main")
windows := app.Windows.GetAll()
window, exists := app.Window.GetByName("main")
windows := app.Window.GetAll()
// Window callbacks
app.Windows.OnCreate(func(window Window) {
app.Window.OnCreate(func(window Window) {
// Handle window creation
})
```
### Events Manager
### Event Manager
Handles custom events and application event listening.
```go
// Custom events
app.Events.Emit("userAction", data)
cancelFunc := app.Events.On("userAction", func(e *CustomEvent) {
app.Event.Emit("userAction", data)
cancelFunc := app.Event.On("userAction", func(e *CustomEvent) {
// Handle event
})
app.Events.Off("userAction")
app.Events.Reset() // Remove all listeners
app.Event.Off("userAction")
app.Event.Reset() // Remove all listeners
// Application events
app.Events.OnApplicationEvent(events.Common.ThemeChanged, func(e *ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ThemeChanged, func(e *ApplicationEvent) {
// Handle system theme change
})
```
@ -124,103 +124,103 @@ if app.Env.IsDarkMode() {
err := app.Env.OpenFileManager("/path/to/folder", false)
```
### Dialogs Manager
### Dialog Manager
Organized access to file and message dialogs.
```go
// File dialogs
result, err := app.Dialogs.OpenFile().
result, err := app.Dialog.OpenFile().
AddFilter("Text Files", "*.txt").
PromptForSingleSelection()
result, err = app.Dialogs.SaveFile().
result, err = app.Dialog.SaveFile().
SetDefaultFilename("document.txt").
PromptForSingleSelection()
// Message dialogs
app.Dialogs.Info().
app.Dialog.Info().
SetTitle("Information").
SetMessage("Operation completed successfully").
Show()
app.Dialogs.Error().
app.Dialog.Error().
SetTitle("Error").
SetMessage("An error occurred").
Show()
```
### Menus Manager
### Menu Manager
Application menu creation and management.
```go
// Create and set application menu
menu := app.Menus.New()
menu := app.Menu.New()
fileMenu := menu.AddSubmenu("File")
fileMenu.Add("New").OnClick(func(ctx *Context) {
// Handle menu click
})
app.Menus.Set(menu)
app.Menu.Set(menu)
// Show about dialog
app.Menus.ShowAbout()
app.Menu.ShowAbout()
```
### Key Bindings Manager
### Key Binding Manager
Dynamic management of global key bindings.
```go
// Add key bindings
app.KeyBindings.Add("ctrl+n", func(window *WebviewWindow) {
app.KeyBinding.Add("ctrl+n", func(window *WebviewWindow) {
// Handle Ctrl+N
})
app.KeyBindings.Add("ctrl+q", func(window *WebviewWindow) {
app.KeyBinding.Add("ctrl+q", func(window *WebviewWindow) {
app.Quit()
})
// Remove key bindings
app.KeyBindings.Remove("ctrl+n")
app.KeyBinding.Remove("ctrl+n")
// Get all bindings
bindings := app.KeyBindings.GetAll()
bindings := app.KeyBinding.GetAll()
```
### Context Menus Manager
### Context Menu Manager
Advanced context menu management (for library authors).
```go
// Create and register context menu
menu := app.ContextMenus.New()
app.ContextMenus.Add("myMenu", menu)
menu := app.ContextMenu.New()
app.ContextMenu.Add("myMenu", menu)
// Retrieve context menu
menu, exists := app.ContextMenus.Get("myMenu")
menu, exists := app.ContextMenu.Get("myMenu")
// Remove context menu
app.ContextMenus.Remove("myMenu")
app.ContextMenu.Remove("myMenu")
```
### Screens Manager
### Screen Manager
Screen management and coordinate transformations for multi-monitor setups.
```go
// Get screen information
screens := app.Screens.GetAll()
primary := app.Screens.GetPrimary()
screens := app.Screen.GetAll()
primary := app.Screen.GetPrimary()
// Coordinate transformations
physicalPoint := app.Screens.DipToPhysicalPoint(logicalPoint)
logicalPoint := app.Screens.PhysicalToDipPoint(physicalPoint)
physicalPoint := app.Screen.DipToPhysicalPoint(logicalPoint)
logicalPoint := app.Screen.PhysicalToDipPoint(physicalPoint)
// Screen detection
screen := app.Screens.ScreenNearestDipPoint(point)
screen = app.Screens.ScreenNearestDipRect(rect)
screen := app.Screen.ScreenNearestDipPoint(point)
screen = app.Screen.ScreenNearestDipRect(rect)
```
### Clipboard Manager
@ -254,7 +254,7 @@ systray.SetLabel("My App")
systray.SetIcon(iconBytes)
// Add menu to system tray
menu := app.Menus.New()
menu := app.Menu.New()
menu.Add("Open").OnClick(func(ctx *Context) {
// Handle click
})

View file

@ -120,7 +120,7 @@ notifier.OnNotificationResponse(func(result notifications.NotificationResult) {
}
// Emit an event to the frontend
app.Events.Emit("notification", result.Response)
app.Event.Emit("notification", result.Response)
})
```

View file

@ -18,7 +18,7 @@ app := application.New(application.Options{
})
// Access the screen manager
screens := app.Screens
screens := app.Screen
```
## Getting Screen Information
@ -28,7 +28,7 @@ screens := app.Screens
Retrieve information about all connected displays:
```go
allScreens := app.Screens.GetAll()
allScreens := app.Screen.GetAll()
for i, screen := range allScreens {
app.Logger.Info("Screen info",
"index", i,
@ -47,7 +47,7 @@ for i, screen := range allScreens {
Get the primary (main) display:
```go
primaryScreen := app.Screens.GetPrimary()
primaryScreen := app.Screen.GetPrimary()
if primaryScreen != nil {
app.Logger.Info("Primary screen",
"name", primaryScreen.Name,
@ -88,7 +88,7 @@ Wails handles two coordinate systems:
- **Physical**: Actual pixel coordinates on the hardware
```go
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
// Logical coordinates (what you typically work with)
logicalWidth := screen.Size.Width
@ -112,11 +112,11 @@ Convert coordinates between logical and physical systems:
```go
// Convert logical point to physical coordinates
logicalPoint := application.Point{X: 100, Y: 50}
physicalPoint := app.Screens.DipToPhysicalPoint(logicalPoint)
physicalPoint := app.Screen.DipToPhysicalPoint(logicalPoint)
// Convert physical point to logical coordinates
physicalPoint2 := application.Point{X: 200, Y: 100}
logicalPoint2 := app.Screens.PhysicalToDipPoint(physicalPoint2)
logicalPoint2 := app.Screen.PhysicalToDipPoint(physicalPoint2)
app.Logger.Info("Coordinate conversion",
"logical", logicalPoint,
@ -137,10 +137,10 @@ logicalRect := application.Rect{
}
// Convert to physical coordinates
physicalRect := app.Screens.DipToPhysicalRect(logicalRect)
physicalRect := app.Screen.DipToPhysicalRect(logicalRect)
// Convert back to logical coordinates
logicalRect2 := app.Screens.PhysicalToDipRect(physicalRect)
logicalRect2 := app.Screen.PhysicalToDipRect(physicalRect)
app.Logger.Info("Rectangle conversion",
"original", logicalRect,
@ -158,11 +158,11 @@ Determine which screen contains a specific point:
```go
// Find screen containing a logical point
point := application.Point{X: 500, Y: 300}
screen := app.Screens.ScreenNearestDipPoint(point)
screen := app.Screen.ScreenNearestDipPoint(point)
// Find screen containing a physical point
physicalPoint := application.Point{X: 1000, Y: 600}
screenPhys := app.Screens.ScreenNearestPhysicalPoint(physicalPoint)
screenPhys := app.Screen.ScreenNearestPhysicalPoint(physicalPoint)
app.Logger.Info("Screen detection",
"point", point,
@ -179,11 +179,11 @@ Determine which screen best contains or overlaps with a rectangle:
```go
// Find screen for a logical rectangle
rect := application.Rect{X: 200, Y: 150, Width: 800, Height: 600}
screen := app.Screens.ScreenNearestDipRect(rect)
screen := app.Screen.ScreenNearestDipRect(rect)
// Find screen for a physical rectangle
physicalRect := application.Rect{X: 400, Y: 300, Width: 1600, Height: 1200}
screenPhys := app.Screens.ScreenNearestPhysicalRect(physicalRect)
screenPhys := app.Screen.ScreenNearestPhysicalRect(physicalRect)
app.Logger.Info("Screen detection by area",
"rect", rect,
@ -211,9 +211,9 @@ func positionWindowOnScreen(window *application.WebviewWindow, targetScreen *app
}
// Usage
primaryScreen := app.Screens.GetPrimary()
primaryScreen := app.Screen.GetPrimary()
if primaryScreen != nil {
window := app.Windows.New()
window := app.Window.New()
positionWindowOnScreen(window, primaryScreen)
}
```
@ -224,14 +224,14 @@ Manage windows across multiple screens:
```go
func distributeWindowsAcrossScreens(app *application.App) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
if len(screens) == 0 {
return
}
// Create one window per screen
for i, screen := range screens {
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: fmt.Sprintf("window-%d", i),
Title: fmt.Sprintf("Window on %s", screen.Name),
Width: 800,
@ -254,7 +254,7 @@ Properly handle displays with different DPI settings:
```go
func analyzeDisplayScaling(app *application.App) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
for _, screen := range screens {
scaleFactor := screen.ScaleFactor
@ -291,7 +291,7 @@ func getDPIAwareSizes(screen *application.Screen, logicalSize int) (int, int) {
}
// Usage
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
logicalWidth, physicalWidth := getDPIAwareSizes(screen, 400)
app.Logger.Info("Size conversion",
"logical", logicalWidth,
@ -317,7 +317,7 @@ app.Logger.Info("Size conversion",
// macOS-specific screen handling
if runtime.GOOS == "darwin" {
// Handle coordinate system differences
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
// Y coordinates are flipped on macOS
}
```
@ -337,7 +337,7 @@ app.Logger.Info("Size conversion",
```go
// Windows-specific screen handling
if runtime.GOOS == "windows" {
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
// Account for taskbar in work area
workArea := screen.WorkArea
}
@ -358,7 +358,7 @@ app.Logger.Info("Size conversion",
```go
// Linux-specific screen handling
if runtime.GOOS == "linux" {
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
// Handle different desktop environments
}
```
@ -370,7 +370,7 @@ app.Logger.Info("Size conversion",
1. **Always Check for Screens**: Ensure screens are available before using them:
```go
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
if len(screens) == 0 {
app.Logger.Warn("No screens detected")
return
@ -379,14 +379,14 @@ app.Logger.Info("Size conversion",
2. **Use Work Areas**: Position windows within work areas to avoid taskbars/docks:
```go
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
workArea := screen.WorkArea
// Position within workArea, not full screen bounds
```
3. **Handle Scale Factors**: Always consider DPI scaling for proper sizing:
```go
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
if screen.ScaleFactor > 1.0 {
// Adjust UI elements for high-DPI displays
}
@ -396,7 +396,7 @@ app.Logger.Info("Size conversion",
```go
app.OnApplicationEvent(events.Common.SystemDisplayChanged, func(event *application.ApplicationEvent) {
// Refresh screen information
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
// Reposition windows if needed
})
```
@ -435,10 +435,10 @@ func main() {
}
func analyzeScreens(app *application.App) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
app.Logger.Info("Screen analysis", "count", len(screens))
primary := app.Screens.GetPrimary()
primary := app.Screen.GetPrimary()
if primary != nil {
app.Logger.Info("Primary screen",
"name", primary.Name,
@ -460,10 +460,10 @@ func analyzeScreens(app *application.App) {
}
func createPositionedWindows(app *application.App) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
for i, screen := range screens {
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: fmt.Sprintf("screen-%d", i),
Title: fmt.Sprintf("Window on %s", screen.Name),
Width: 600,
@ -488,7 +488,7 @@ func monitorScreenChanges(app *application.App) {
app.Logger.Info("Screen configuration changed")
// Re-analyze screens
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
app.Logger.Info("Updated screen count", "count", len(screens))
// Could reposition windows here if needed

View file

@ -18,7 +18,7 @@ app := application.New(application.Options{
})
// Access the window manager
windowManager := app.Windows
windowManager := app.Window
```
## Creating Windows
@ -28,7 +28,7 @@ windowManager := app.Windows
Create a new window with default settings:
```go
window := app.Windows.New()
window := app.Window.New()
```
### Window Creation with Options
@ -36,7 +36,7 @@ window := app.Windows.New()
Create a window with custom configuration:
```go
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Custom Window",
Width: 800,
Height: 600,
@ -59,7 +59,7 @@ window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
Retrieve a window using its name:
```go
window, exists := app.Windows.GetByName("main-window")
window, exists := app.Window.GetByName("main-window")
if exists {
// Work with the window
window.SetTitle("Found Window")
@ -71,7 +71,7 @@ if exists {
Retrieve a window using its unique ID:
```go
window, exists := app.Windows.GetByID(123)
window, exists := app.Window.GetByID(123)
if exists {
// Work with the window
}
@ -83,13 +83,13 @@ Get the currently active/focused window:
```go
// Get current window (may be nil)
currentWindow := app.Windows.Current()
currentWindow := app.Window.Current()
if currentWindow != nil {
currentWindow.SetTitle("Active Window")
}
// Get current window with existence check
currentWindow, exists := app.Windows.GetCurrent()
currentWindow, exists := app.Window.GetCurrent()
if exists {
currentWindow.SetTitle("Active Window")
}
@ -100,7 +100,7 @@ if exists {
Retrieve all windows managed by the application:
```go
allWindows := app.Windows.GetAll()
allWindows := app.Window.GetAll()
for i, window := range allWindows {
window.SetTitle(fmt.Sprintf("Window %d", i+1))
}
@ -113,7 +113,7 @@ for i, window := range allWindows {
Register callbacks to be notified when new windows are created:
```go
app.Windows.OnCreate(func(window application.Window) {
app.Window.OnCreate(func(window application.Window) {
app.Logger.Info("New window created", "name", window.Name())
// Configure the window
@ -129,10 +129,10 @@ Remove windows from the manager:
```go
// Remove by ID
app.Windows.Remove(windowID)
app.Window.Remove(windowID)
// Remove by name
removed := app.Windows.RemoveByName("window-name")
removed := app.Window.RemoveByName("window-name")
if removed {
app.Logger.Info("Window removed successfully")
}
@ -145,7 +145,7 @@ if removed {
The primary window type in Wails v3 is the WebView window, which embeds a web browser:
```go
window := app.Windows.New()
window := app.Window.New()
// WebView-specific operations
window.SetURL("https://example.com")
@ -179,14 +179,14 @@ Create and manage multiple windows for complex applications:
```go
// Create main window
mainWindow := app.Windows.NewWithOptions(application.WebviewWindowOptions{
mainWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Main Application",
Width: 1200,
Height: 800,
})
// Create settings window
settingsWindow := app.Windows.NewWithOptions(application.WebviewWindowOptions{
settingsWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Settings",
Width: 600,
Height: 400,
@ -203,10 +203,10 @@ Windows can communicate through events:
```go
// In window A
app.Events.Emit("data-updated", newData)
app.Event.Emit("data-updated", newData)
// In window B
app.Events.On("data-updated", func(event *application.CustomEvent) {
app.Event.On("data-updated", func(event *application.CustomEvent) {
// Update UI with new data
data := event.Data
// Process data...
@ -257,7 +257,7 @@ app.Events.On("data-updated", func(event *application.CustomEvent) {
1. **Window Naming**: Always provide meaningful names for windows to make them easy to find:
```go
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "settings-window",
Title: "Application Settings",
})
@ -266,20 +266,20 @@ app.Events.On("data-updated", func(event *application.CustomEvent) {
2. **Resource Management**: Properly clean up windows when they're no longer needed:
```go
window.OnEvent(events.Common.WindowClosing, func(e *application.WindowEvent) {
app.Windows.Remove(window.ID())
app.Window.Remove(window.ID())
})
```
3. **Window State**: Consider starting secondary windows as hidden and showing them when needed:
```go
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
WindowState: application.WindowStateHidden,
})
```
4. **Error Handling**: Always check if windows exist before using them:
```go
if window, exists := app.Windows.GetByName("main"); exists {
if window, exists := app.Window.GetByName("main"); exists {
window.SetTitle("New Title")
}
```
@ -301,7 +301,7 @@ func main() {
})
// Create main window
mainWindow := app.Windows.NewWithOptions(application.WebviewWindowOptions{
mainWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "main",
Title: "Main Window",
Width: 800,
@ -309,7 +309,7 @@ func main() {
})
// Create hidden settings window
settingsWindow := app.Windows.NewWithOptions(application.WebviewWindowOptions{
settingsWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "settings",
Title: "Settings",
Width: 400,
@ -318,23 +318,23 @@ func main() {
})
// Setup window creation callback
app.Windows.OnCreate(func(window application.Window) {
app.Window.OnCreate(func(window application.Window) {
app.Logger.Info("Window created", "name", window.Name())
})
// Setup menu to show settings
menu := app.Menus.New()
menu := app.Menu.New()
menu.AddRole(application.AppMenu)
settingsMenu := menu.AddSubmenu("Settings")
settingsMenu.Add("Open Settings").OnClick(func(ctx *application.Context) {
if window, exists := app.Windows.GetByName("settings"); exists {
if window, exists := app.Window.GetByName("settings"); exists {
window.Show()
window.Focus()
}
})
app.Menus.Set(menu)
app.Menu.Set(menu)
err := app.Run()
if err != nil {

1
v3/.gitignore vendored
View file

@ -8,3 +8,4 @@ cmd/wails3/wails
/examples/plain/plain
/cmd/wails3/ui/.task/
!internal/commands/webview2/MicrosoftEdgeWebview2Setup.exe
internal/commands/appimage_testfiles/appimage_testfiles

View file

@ -217,6 +217,8 @@ tasks:
- task: test:examples:linux:docker
- echo "=== Testing CLI Code ==="
- task: test:cli
- echo "=== Cleaning Up Test Binaries ==="
- task: clean:test:binaries
test:cli:
summary: Test CLI-related code compilation
@ -273,6 +275,8 @@ tasks:
- task: test:templates
- echo "=== Testing pkg/application ==="
- cd pkg/application && go test -c -o /dev/null ./...
- echo "=== Cleaning Up Test Binaries ==="
- task: clean:test:binaries
- echo "✅ All infrastructure components test successfully"
test:examples:
@ -341,3 +345,25 @@ tasks:
platforms: [windows]
- echo "Testing CLI code..."
- task: test:cli
- echo "=== Cleaning Up Test Binaries ==="
- task: clean:test:binaries
clean:test:binaries:
summary: Clean up all test-generated binary files and directories (cross-platform)
cmds:
- echo "🧹 Cleaning up test binaries..."
- go run tasks/cleanup/cleanup.go
- echo "✅ Test binaries cleaned up"
test:all:
summary: Run all tests including examples, infrastructure, and Go unit tests
cmds:
- echo "=== Running Go Unit Tests ==="
- go test ./...
- echo "=== Testing Examples (Current Platform) ==="
- task: test:examples
- echo "=== Testing Infrastructure Components ==="
- task: test:infrastructure
- echo "=== Cleaning Up Test Binaries ==="
- task: clean:test:binaries
- echo "✅ All tests completed successfully"

View file

@ -56,7 +56,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
@ -67,14 +67,14 @@ func main() {
URL: "/",
})
app.Events.On("remove:badge", func(event *application.CustomEvent) {
app.Event.On("remove:badge", func(event *application.CustomEvent) {
err := badgeService.RemoveBadge()
if err != nil {
log.Fatal(err)
}
})
app.Events.On("set:badge", func(event *application.CustomEvent) {
app.Event.On("set:badge", func(event *application.CustomEvent) {
text := event.Data.(string)
err := badgeService.SetBadge(text)
if err != nil {
@ -91,7 +91,7 @@ func main() {
select {
case <-ticker.C:
now := time.Now().Format(time.RFC1123)
app.Events.Emit("time", now)
app.Event.Emit("time", now)
case <-app.Context().Done():
return
}

View file

@ -49,7 +49,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
@ -61,14 +61,14 @@ func main() {
})
// Store cleanup functions for proper resource management
removeBadgeHandler := app.Events.On("remove:badge", func(event *application.CustomEvent) {
removeBadgeHandler := app.Event.On("remove:badge", func(event *application.CustomEvent) {
err := badgeService.RemoveBadge()
if err != nil {
log.Fatal(err)
}
})
setBadgeHandler := app.Events.On("set:badge", func(event *application.CustomEvent) {
setBadgeHandler := app.Event.On("set:badge", func(event *application.CustomEvent) {
text := event.Data.(string)
err := badgeService.SetBadge(text)
if err != nil {
@ -92,7 +92,7 @@ func main() {
select {
case <-ticker.C:
now := time.Now().Format(time.RFC1123)
app.Events.Emit("time", now)
app.Event.Emit("time", now)
case <-app.Context().Done():
return
}

View file

@ -23,7 +23,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
URL: "/",
DevToolsEnabled: true,
})

View file

@ -25,13 +25,13 @@ func main() {
},
})
app.Events.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(*application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(*application.ApplicationEvent) {
log.Println("ApplicationDidFinishLaunching")
})
currentWindow := func(fn func(window *application.WebviewWindow)) {
if app.Windows.Current() != nil {
fn(app.Windows.Current())
if app.Window.Current() != nil {
fn(app.Window.Current())
} else {
println("Current WebviewWindow is nil")
}
@ -51,7 +51,7 @@ func main() {
myMenu.Add("New WebviewWindow").
SetAccelerator("CmdOrCtrl+N").
OnClick(func(ctx *application.Context) {
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
@ -61,7 +61,7 @@ func main() {
myMenu.Add("New Frameless WebviewWindow").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
X: rand.Intn(1000),
Y: rand.Intn(800),
Frameless: true,
@ -74,7 +74,7 @@ func main() {
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
@ -88,7 +88,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
@ -102,7 +102,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
@ -238,12 +238,12 @@ func main() {
})
})
stateMenu.Add("Get Primary Screen").OnClick(func(ctx *application.Context) {
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
})
stateMenu.Add("Get Screens").OnClick(func(ctx *application.Context) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
for _, screen := range screens {
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
@ -260,9 +260,9 @@ func main() {
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
})
})
app.Windows.New()
app.Window.New()
app.Menus.Set(menu)
app.Menu.Set(menu)
err := app.Run()
if err != nil {

View file

@ -23,7 +23,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
URL: "/",
DevToolsEnabled: true,
})

View file

@ -23,7 +23,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
URL: "/",
DevToolsEnabled: true,
})

View file

@ -65,9 +65,9 @@ func main() {
}
})
app.Menus.Set(menu)
app.Menu.Set(menu)
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -24,7 +24,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Context Menu Demo",
Width: 1024,
Height: 1024,
@ -35,7 +35,7 @@ func main() {
},
})
contextMenu := app.ContextMenus.New()
contextMenu := app.ContextMenu.New()
clickMe := contextMenu.Add("Click to set Menuitem label to Context Data")
contextDataMenuItem := contextMenu.Add("Current context data: No Context Data")
clickMe.OnClick(func(data *application.Context) {
@ -45,7 +45,7 @@ func main() {
})
// Register the context menu
app.ContextMenus.Add("test", contextMenu)
app.ContextMenu.Add("test", contextMenu)
err := app.Run()

View file

@ -23,7 +23,7 @@ func main() {
},
})
// Create window
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{

View file

@ -23,7 +23,7 @@ func main() {
})
// Create main window
mainWindow := app.Windows.NewWithOptions(application.WebviewWindowOptions{
mainWindow := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Dialog Tests",
Width: 800,
Height: 600,
@ -34,7 +34,7 @@ func main() {
// Create main menu
menu := app.NewMenu()
app.Menus.Set(menu)
app.Menu.Set(menu)
menu.AddRole(application.AppMenu)
menu.AddRole(application.EditMenu)
menu.AddRole(application.WindowMenu)

View file

@ -60,7 +60,7 @@ func main() {
dialog.Show()
})
infoMenu.Add("About").OnClick(func(ctx *application.Context) {
app.Menus.ShowAbout()
app.Menu.ShowAbout()
})
questionMenu := menu.AddSubmenu("Question")
@ -73,7 +73,7 @@ func main() {
})
questionMenu.Add("Question (Attached to Window)").OnClick(func(ctx *application.Context) {
dialog := application.QuestionDialog()
dialog.AttachToWindow(app.Windows.Current())
dialog.AttachToWindow(app.Window.Current())
dialog.SetMessage("No default button")
dialog.AddButton("Yes")
dialog.AddButton("No")
@ -196,7 +196,7 @@ func main() {
CanChooseFiles(true).
CanCreateDirectories(true).
ShowHiddenFiles(true).
AttachToWindow(app.Windows.Current()).
AttachToWindow(app.Window.Current()).
PromptForSingleSelection()
if result != "" {
application.InfoDialog().SetMessage(result).Show()
@ -310,7 +310,7 @@ func main() {
})
saveMenu.Add("Select File (Attach To WebviewWindow)").OnClick(func(ctx *application.Context) {
result, _ := application.SaveFileDialog().
AttachToWindow(app.Windows.Current()).
AttachToWindow(app.Window.Current()).
PromptForSingleSelection()
if result != "" {
application.InfoDialog().SetMessage(result).Show()
@ -350,9 +350,9 @@ func main() {
}
})
app.Menus.Set(menu)
app.Menu.Set(menu)
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -25,7 +25,7 @@ func main() {
},
})
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Drag-n-drop Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
@ -37,7 +37,7 @@ func main() {
window.OnWindowEvent(events.Common.WindowFilesDropped, func(event *application.WindowEvent) {
files := event.Context().DroppedFiles()
app.Events.Emit("files", files)
app.Event.Emit("files", files)
app.Logger.Info("Files Dropped!", "files", files)
})

View file

@ -24,7 +24,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Environment Demo",
Width: 800,
Height: 600,

View file

@ -28,7 +28,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "Window 1",
Title: "Window 1",
URL: "https://wails.io",
@ -39,7 +39,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "Window 2",
Title: "Window 2",
URL: "https://google.com",

View file

@ -27,12 +27,12 @@ func main() {
})
// Custom event handling
app.Events.On("myevent", func(e *application.CustomEvent) {
app.Event.On("myevent", func(e *application.CustomEvent) {
app.Logger.Info("[Go] CustomEvent received", "name", e.Name, "data", e.Data, "sender", e.Sender, "cancelled", e.IsCancelled())
})
// OS specific application events
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
go func() {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
@ -41,7 +41,7 @@ func main() {
case <-ticker.C:
// This emits a custom event every 10 seconds
// As it's sent from the application, the sender will be blank
app.Events.Emit("myevent", "hello")
app.Event.Emit("myevent", "hello")
case <-app.Context().Done():
return
}
@ -49,7 +49,7 @@ func main() {
}()
})
app.Events.OnApplicationEvent(events.Common.ThemeChanged, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ThemeChanged, func(event *application.ApplicationEvent) {
app.Logger.Info("System theme changed!")
if event.Context().IsDarkMode() {
app.Logger.Info("System is now using dark mode!")
@ -59,11 +59,11 @@ func main() {
})
// Platform agnostic events
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
app.Logger.Info("events.Common.ApplicationStarted fired!")
})
win1 := app.Windows.NewWithOptions(application.WebviewWindowOptions{
win1 := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Name: "Window 1",
Mac: application.MacWindow{
@ -85,7 +85,7 @@ func main() {
e.Cancel()
})
win2 := app.Windows.NewWithOptions(application.WebviewWindowOptions{
win2 := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 2",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,

View file

@ -48,7 +48,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
@ -60,7 +60,7 @@ func main() {
})
var filename string
app.Events.OnApplicationEvent(events.Common.ApplicationOpenedWithFile, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationOpenedWithFile, func(event *application.ApplicationEvent) {
filename = event.Context().Filename()
})
@ -80,7 +80,7 @@ func main() {
select {
case <-ticker.C:
now := time.Now().Format(time.RFC1123)
app.Events.Emit("time", now)
app.Event.Emit("time", now)
case <-app.Context().Done():
return
}

View file

@ -24,7 +24,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Frameless: true,
})

View file

@ -94,14 +94,14 @@ func main() {
})
// Register event handler and store cleanup function
removeGinHandler := app.Events.On("gin-button-clicked", func(event *application.CustomEvent) {
removeGinHandler := app.Event.On("gin-button-clicked", func(event *application.CustomEvent) {
log.Printf("Received event from frontend: %v", event.Data)
})
// Note: In production, call removeGinHandler() during cleanup
_ = removeGinHandler
// Create window
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Wails + Gin Example",
Width: 900,
Height: 700,

View file

@ -94,12 +94,12 @@ func main() {
})
// Register event handler
app.Events.On("gin-button-clicked", func(event *application.CustomEvent) {
app.Event.On("gin-button-clicked", func(event *application.CustomEvent) {
log.Printf("Received event from frontend: %v", event.Data)
})
// Create window
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Wails + Gin Example",
Width: 900,
Height: 700,

View file

@ -30,7 +30,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Gin Service Demo",
Width: 1024,
Height: 768,

View file

@ -74,13 +74,13 @@ func (s *GinService) ServiceStartup(ctx context.Context, options application.Ser
// Register an event handler that can be triggered from the frontend
// Store the cleanup function for proper resource management
s.removeEventHandler = s.app.Events.On("gin-api-event", func(event *application.CustomEvent) {
s.removeEventHandler = s.app.Event.On("gin-api-event", func(event *application.CustomEvent) {
// Log the event data
// Parse the event data
s.app.Logger.Info("Received event from frontend", "data", event.Data)
// You could also emit an event back to the frontend
s.app.Events.Emit("gin-api-response", map[string]interface{}{
s.app.Event.Emit("gin-api-response", map[string]interface{}{
"message": "Response from Gin API Service",
"time": time.Now().Format(time.RFC3339),
})
@ -189,7 +189,7 @@ func (s *GinService) setupRoutes() {
c.JSON(http.StatusCreated, newUser)
// Emit an event to notify about the new user
s.app.Events.Emit("user-created", newUser)
s.app.Event.Emit("user-created", newUser)
})
// Delete a user

View file

@ -21,7 +21,7 @@ func main() {
systemTray := app.SystemTray.New()
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 500,
Height: 800,
Frameless: false,
@ -43,7 +43,7 @@ func main() {
}
// Click Dock icon tigger application show
app.Events.OnApplicationEvent(events.Mac.ApplicationShouldHandleReopen, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Mac.ApplicationShouldHandleReopen, func(event *application.ApplicationEvent) {
println("reopen")
window.Show()
})

View file

@ -23,7 +23,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Drag-n-drop Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,

View file

@ -16,7 +16,7 @@ func main() {
},
})
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 800,
Height: 600,
Title: "Ignore Mouse Example",

View file

@ -20,7 +20,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "Window 1",
Title: "Window 1",
URL: "https://wails.io",
@ -31,7 +31,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Name: "Window 2",
Title: "Window 2",
URL: "https://google.com",

View file

@ -56,11 +56,11 @@ func main() {
// You can control the current window from the menu
myMenu.Add("Lock WebviewWindow Resize").OnClick(func(ctx *application.Context) {
if app.Windows.Current().Resizable() {
app.Windows.Current().SetResizable(false)
if app.Window.Current().Resizable() {
app.Window.Current().SetResizable(false)
ctx.ClickedMenuItem().SetLabel("Unlock WebviewWindow Resize")
} else {
app.Windows.Current().SetResizable(true)
app.Window.Current().SetResizable(true)
ctx.ClickedMenuItem().SetLabel("Lock WebviewWindow Resize")
}
})
@ -144,9 +144,9 @@ func main() {
}
})
app.Menus.Set(menu)
app.Menu.Set(menu)
window := app.Windows.New().SetBackgroundColour(application.NewRGB(33, 37, 41))
window := app.Window.New().SetBackgroundColour(application.NewRGB(33, 37, 41))
window.SetMenu(menu)
err := app.Run()

View file

@ -49,7 +49,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Name: "main",
Mac: application.MacWindow{
@ -68,7 +68,7 @@ func main() {
} else {
fmt.Printf("Response: %+v\n", result.Response)
println("Sending response to frontend...")
app.Events.Emit("notification:action", result.Response)
app.Event.Emit("notification:action", result.Response)
}
})

View file

@ -48,7 +48,7 @@ func main() {
},
})
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow 1").
Show()

View file

@ -25,7 +25,7 @@ func main() {
})
// Create window - Note: In future versions, window creation may return errors
// that should be checked. For now, window creation is deferred until app.Run()
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgb(255, 255, 255); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
@ -37,7 +37,7 @@ func main() {
})
// Create second window with direct HTML content
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "HTML TEST",
HTML: "<h1>AWESOME!</h1>",
CSS: `body { background-color: rgb(255, 0, 0); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .main { color: white; margin: 20%; }`,
@ -45,7 +45,7 @@ func main() {
})
// Store the cleanup function to remove event listener when needed
removeClickHandler := app.Events.On("clicked", func(_ *application.CustomEvent) {
removeClickHandler := app.Event.On("clicked", func(_ *application.CustomEvent) {
println("clicked")
})
// Note: In a real application, you would call removeClickHandler() when appropriate
@ -60,7 +60,7 @@ func main() {
select {
case <-ticker.C:
// Create window after delay - in production, you should handle potential errors
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Plain Bundle new Window from GoRoutine",
Width: 500,
Height: 500,

View file

@ -26,7 +26,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Name: "Window 1",
Mac: application.MacWindow{

View file

@ -59,7 +59,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Screen Demo",
Width: 800,
Height: 600,

View file

@ -13,7 +13,7 @@ type ScreenService struct {
func (s *ScreenService) GetSystemScreens() []*application.Screen {
s.isExampleLayout = false
screens := application.Get().Screens.GetAll()
screens := application.Get().Screen.GetAll()
return screens
}

View file

@ -55,7 +55,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 1024,
Height: 768,
})

View file

@ -17,7 +17,7 @@ func main() {
})
// Create window
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Toolbar hidden (default behaviour)",
HTML: "<html><body><h1>Switch this window to fullscreen: the toolbar will be hidden</h1></body></html>",
CSS: `body { background-color: blue; color: white; height: 100vh; display: flex; justify-content: center; align-items: center; }`,
@ -30,7 +30,7 @@ func main() {
})
// Create window
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Toolbar visible",
HTML: "<html><body><h1>Switch this window to fullscreen: the toolbar will stay visible</h1></body></html>",
CSS: `body { background-color: red; color: white; height: 100vh; display: flex; justify-content: center; align-items: center; }`,

View file

@ -63,7 +63,7 @@ func main() {
},
})
window = app.Windows.NewWithOptions(application.WebviewWindowOptions{
window = app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Single Instance Demo",
Width: 800,
Height: 700,

View file

@ -22,7 +22,7 @@ func main() {
systemTray := app.SystemTray.New()
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 500,
Height: 500,
Name: "Systray Demo Window",

View file

@ -16,7 +16,7 @@ func createWindow(app *application.App) {
return
}
// Log the time taken to create the window
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 500,
Height: 500,
Name: "Systray Demo Window",

View file

@ -26,7 +26,7 @@ func main() {
systemTray := app.SystemTray.New()
window := app.Windows.NewWithOptions(application.WebviewWindowOptions{
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
Width: 500,
Height: 500,
Name: "Systray Demo Window",

View file

@ -23,11 +23,11 @@ func main() {
WebviewBrowserPath: "",
},
})
app.Events.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(event *application.ApplicationEvent) {
log.Println("ApplicationDidFinishLaunching")
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
BackgroundColour: application.NewRGB(33, 37, 41),
Mac: application.MacWindow{
DisableShadow: true,

View file

@ -23,7 +23,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "JS Window API Demo",
Width: 1280,
Height: 1024,

View file

@ -38,7 +38,7 @@ func main() {
},
})
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow 1").
Show()
@ -56,14 +56,14 @@ func main() {
myMenu.Add("New WebviewWindow").
SetAccelerator("CmdOrCtrl+N").
OnClick(func(ctx *application.Context) {
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
Show()
windowCounter++
})
app.Menus.Set(menu)
app.Menu.Set(menu)
err := app.Run()
if err != nil {

View file

@ -28,16 +28,16 @@ func main() {
editMenu := menu.AddSubmenu("MenuBar")
editMenu.Add("Hide MenuBar").OnClick(func(ctx *application.Context) {
app.Windows.Current().HideMenuBar()
app.Window.Current().HideMenuBar()
})
helpMenu := menu.AddSubmenu("Help")
helpMenu.Add("About").OnClick(func(ctx *application.Context) {
app.Windows.Current().SetURL("/about.html")
app.Window.Current().SetURL("/about.html")
})
// Create window with menu
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window MenuBar Demo",
Width: 800,
Height: 600,

View file

@ -27,7 +27,7 @@ type WindowService struct{}
// ==============================================
func (s *WindowService) SetPos(relative bool, x, y float64) {
win := application.Get().Windows.Current()
win := application.Get().Window.Current()
initX, initY := win.Position()
if relative {
x += float64(initX)
@ -38,7 +38,7 @@ func (s *WindowService) SetPos(relative bool, x, y float64) {
fmt.Printf("SetPos: %d, %d => %d, %d\n", initX, initY, currentX, currentY)
}
func (s *WindowService) SetSize(relative bool, wdt, hgt float64) {
win := application.Get().Windows.Current()
win := application.Get().Window.Current()
initW, initH := win.Size()
if relative {
wdt += float64(initW)
@ -49,7 +49,7 @@ func (s *WindowService) SetSize(relative bool, wdt, hgt float64) {
fmt.Printf("SetSize: %d, %d => %d, %d\n", initW, initH, currentW, currentH)
}
func (s *WindowService) SetBounds(x, y, w, h float64) {
win := application.Get().Windows.Current()
win := application.Get().Window.Current()
initR := win.Bounds()
win.SetBounds(application.Rect{
X: int(x),
@ -61,7 +61,7 @@ func (s *WindowService) SetBounds(x, y, w, h float64) {
fmt.Printf("SetBounds: %+v => %+v\n", initR, currentR)
}
func (s *WindowService) GetBounds() application.Rect {
win := application.Get().Windows.Current()
win := application.Get().Window.Current()
r := win.Bounds()
mid := r.X + (r.Width-1)/2
fmt.Printf("GetBounds: %+v: mid: %d\n", r, mid)
@ -84,15 +84,15 @@ func main() {
application.NewService(&WindowService{}),
},
})
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(event *application.ApplicationEvent) {
log.Println("ApplicationDidFinishLaunching")
})
var hiddenWindows []*application.WebviewWindow
currentWindow := func(fn func(window *application.WebviewWindow)) {
if app.Windows.Current() != nil {
fn(app.Windows.Current())
if app.Window.Current() != nil {
fn(app.Window.Current())
} else {
println("Current WebviewWindow is nil")
}
@ -113,7 +113,7 @@ func main() {
myMenu.Add("New WebviewWindow").
SetAccelerator("CmdOrCtrl+N").
OnClick(func(ctx *application.Context) {
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
@ -123,7 +123,7 @@ func main() {
if runtime.GOOS != "linux" {
myMenu.Add("New WebviewWindow (Disable Minimise)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MinimiseButtonState: application.ButtonDisabled,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -134,7 +134,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Disable Maximise)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MaximiseButtonState: application.ButtonDisabled,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -145,7 +145,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Hide Minimise)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MinimiseButtonState: application.ButtonHidden,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -156,7 +156,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Always on top)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
AlwaysOnTop: true,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -167,7 +167,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Hide Maximise)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MaximiseButtonState: application.ButtonHidden,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -179,7 +179,7 @@ func main() {
myMenu.Add("New WebviewWindow (Centered)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MaximiseButtonState: application.ButtonHidden,
InitialPosition: application.WindowCentered,
}).
@ -191,7 +191,7 @@ func main() {
myMenu.Add("New WebviewWindow (Position 100,100)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
MaximiseButtonState: application.ButtonHidden,
X: 100,
Y: 100,
@ -206,7 +206,7 @@ func main() {
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
myMenu.Add("New WebviewWindow (Disable Close)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
CloseButtonState: application.ButtonDisabled,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -217,7 +217,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Hide Close)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
CloseButtonState: application.ButtonHidden,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
@ -232,7 +232,7 @@ func main() {
if runtime.GOOS == "windows" {
myMenu.Add("New WebviewWindow (Custom ExStyle)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Windows: application.WindowsWindow{
ExStyle: getExStyle(),
},
@ -246,7 +246,7 @@ func main() {
}
myMenu.Add("New WebviewWindow (Listen to Move)").
OnClick(func(ctx *application.Context) {
w := app.Windows.NewWithOptions(application.WebviewWindowOptions{}).
w := app.Window.NewWithOptions(application.WebviewWindowOptions{}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
@ -259,7 +259,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Listen to Resize)").
OnClick(func(ctx *application.Context) {
w := app.Windows.NewWithOptions(application.WebviewWindowOptions{}).
w := app.Window.NewWithOptions(application.WebviewWindowOptions{}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
@ -274,7 +274,7 @@ func main() {
myMenu.Add("New WebviewWindow (Hides on Close one time)").
SetAccelerator("CmdOrCtrl+H").
OnClick(func(ctx *application.Context) {
w := app.Windows.New()
w := app.Window.New()
w.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
if !lo.Contains(hiddenWindows, w) {
@ -301,7 +301,7 @@ func main() {
myMenu.Add("New WebviewWindow (Frameless)").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
X: rand.Intn(1000),
Y: rand.Intn(800),
BackgroundColour: application.NewRGB(33, 37, 41),
@ -315,7 +315,7 @@ func main() {
myMenu.Add("New WebviewWindow (Ignores mouse events)").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
HTML: "<div style='width: 100%; height: 95%; border: 3px solid red; background-color: \"0000\";'></div>",
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -330,7 +330,7 @@ func main() {
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
@ -345,7 +345,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
@ -359,7 +359,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
@ -375,7 +375,7 @@ func main() {
if runtime.GOOS == "windows" {
myMenu.Add("New WebviewWindow (Mica)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -408,7 +408,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Acrylic)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -441,7 +441,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Tabbed)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -667,12 +667,12 @@ func main() {
})
})
stateMenu.Add("Get Primary Screen").OnClick(func(ctx *application.Context) {
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
})
stateMenu.Add("Get Screens").OnClick(func(ctx *application.Context) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
for _, screen := range screens {
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
@ -720,7 +720,7 @@ func main() {
})
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window Demo",
BackgroundColour: application.NewRGB(33, 37, 41),
Mac: application.MacWindow{
@ -731,7 +731,7 @@ func main() {
},
})
app.Menus.Set(menu)
app.Menu.Set(menu)
err := app.Run()
if err != nil {

View file

@ -24,7 +24,7 @@ func main() {
},
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Wails ML Demo",
Width: 1280,
Height: 1024,
@ -35,10 +35,10 @@ func main() {
},
})
app.Events.On("button-pressed", func(_ *application.CustomEvent) {
app.Event.On("button-pressed", func(_ *application.CustomEvent) {
println("Button Pressed!")
})
app.Events.On("hover", func(_ *application.CustomEvent) {
app.Event.On("hover", func(_ *application.CustomEvent) {
println("Hover time!")
})

View file

@ -24,15 +24,15 @@ func main() {
ApplicationShouldTerminateAfterLastWindowClosed: false,
},
})
app.Events.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(event *application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(event *application.ApplicationEvent) {
log.Println("ApplicationDidFinishLaunching")
})
var hiddenWindows []*application.WebviewWindow
currentWindow := func(fn func(window *application.WebviewWindow)) {
if app.Windows.Current() != nil {
fn(app.Windows.Current())
if app.Window.Current() != nil {
fn(app.Window.Current())
} else {
println("Current WebviewWindow is nil")
}
@ -50,7 +50,7 @@ func main() {
myMenu.Add("New WebviewWindow").
SetAccelerator("CmdOrCtrl+N").
OnClick(func(ctx *application.Context) {
app.Windows.New().
app.Window.New().
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
@ -60,7 +60,7 @@ func main() {
myMenu.Add("New WebviewWindow (Hides on Close one time)").
SetAccelerator("CmdOrCtrl+H").
OnClick(func(ctx *application.Context) {
w := app.Windows.New()
w := app.Window.New()
w.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
if !lo.Contains(hiddenWindows, w) {
hiddenWindows = append(hiddenWindows, w)
@ -83,7 +83,7 @@ func main() {
myMenu.Add("New Frameless WebviewWindow").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
X: rand.Intn(1000),
Y: rand.Intn(800),
BackgroundColour: application.NewRGB(33, 37, 41),
@ -97,7 +97,7 @@ func main() {
myMenu.Add("New WebviewWindow (ignores mouse events").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
HTML: "<div style='width: 100%; height: 95%; border: 3px solid red; background-color: \"0000\";'></div>",
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -112,7 +112,7 @@ func main() {
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
@ -127,7 +127,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
@ -141,7 +141,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
@ -157,7 +157,7 @@ func main() {
if runtime.GOOS == "windows" {
myMenu.Add("New WebviewWindow (Mica)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -171,7 +171,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Acrylic)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -185,7 +185,7 @@ func main() {
})
myMenu.Add("New WebviewWindow (Tabbed)").
OnClick(func(ctx *application.Context) {
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "WebviewWindow " + strconv.Itoa(windowCounter),
X: rand.Intn(1000),
Y: rand.Intn(800),
@ -340,12 +340,12 @@ func main() {
})
})
stateMenu.Add("Get Primary Screen").OnClick(func(ctx *application.Context) {
screen := app.Screens.GetPrimary()
screen := app.Screen.GetPrimary()
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
})
stateMenu.Add("Get Screens").OnClick(func(ctx *application.Context) {
screens := app.Screens.GetAll()
screens := app.Screen.GetAll()
for _, screen := range screens {
msg := fmt.Sprintf("Screen: %+v", screen)
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
@ -386,14 +386,14 @@ func main() {
})
})
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
BackgroundColour: application.NewRGB(33, 37, 41),
Mac: application.MacWindow{
DisableShadow: true,
},
})
app.Menus.SetApplicationMenu(menu)
app.Menu.SetApplicationMenu(menu)
err := app.Run()
if err != nil {

View file

@ -126,7 +126,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -43,7 +43,7 @@ func main() {
app := application.New(options)
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -49,7 +49,7 @@ func main() {
other.CustomNewServices[Service11, Service12]()...),
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -113,7 +113,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -32,7 +32,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -44,7 +44,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -35,7 +35,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -49,7 +49,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -40,7 +40,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -63,7 +63,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -27,7 +27,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -40,7 +40,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -39,7 +39,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -14,7 +14,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -29,7 +29,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -35,7 +35,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -50,7 +50,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -296,7 +296,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -198,7 +198,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -36,7 +36,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -30,7 +30,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -15,7 +15,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -38,7 +38,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -194,7 +194,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -194,7 +194,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -26,7 +26,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -30,8 +30,8 @@ func main() {
},
})
_ = app.Windows.New() // discard
// or: win := app.Windows.New() // keep for later
_ = app.Window.New() // discard
// or: win := app.Window.New() // keep for later
err := app.Run()

View file

@ -42,7 +42,7 @@ func main() {
},
})
app.Windows.New()
app.Window.New()
err := app.Run()

View file

@ -46,7 +46,7 @@ func main() {
// 'Mac' options tailor the window when running on macOS.
// 'BackgroundColour' is the background colour of the window.
// 'URL' is the URL that will be loaded into the webview.
app.Windows.NewWithOptions(application.WebviewWindowOptions{
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
@ -62,7 +62,7 @@ func main() {
go func() {
for {
now := time.Now().Format(time.RFC1123)
app.Events.Emit("time", now)
app.Event.Emit("time", now)
time.Sleep(time.Second)
}
}()

View file

@ -76,7 +76,7 @@ func New(appOptions Options) *App {
result.logStartup()
result.logPlatformInfo()
result.customEventProcessor = NewWailsEventProcessor(result.Events.dispatch)
result.customEventProcessor = NewWailsEventProcessor(result.Event.dispatch)
messageProc := NewMessageProcessor(result.Logger)
opts := &assetserver.Options{
@ -271,17 +271,17 @@ type App struct {
applicationEventHooksLock sync.RWMutex
// Manager pattern for organized API
Windows *WindowManager
ContextMenus *ContextMenuManager
KeyBindings *KeyBindingManager
Browser *BrowserManager
Env *EnvironmentManager
Dialogs *DialogManager
Events *EventManager
Menus *MenuManager
Screens *ScreenManager
Clipboard *ClipboardManager
SystemTray *SystemTrayManager
Window *WindowManager
ContextMenu *ContextMenuManager
KeyBinding *KeyBindingManager
Browser *BrowserManager
Env *EnvironmentManager
Dialog *DialogManager
Event *EventManager
Menu *MenuManager
Screen *ScreenManager
Clipboard *ClipboardManager
SystemTray *SystemTrayManager
// Windows
windows map[uint]Window
@ -308,7 +308,7 @@ type App struct {
// platform app
impl platformApp
// The main application menu (private - use app.Menus.GetApplicationMenu/SetApplicationMenu)
// The main application menu (private - use app.Menu.GetApplicationMenu/SetApplicationMenu)
applicationMenu *Menu
clipboard *Clipboard
@ -419,15 +419,15 @@ func (a *App) init() {
a.wailsEventListeners = make([]WailsEventListener, 0)
// Initialize managers
a.Windows = newWindowManager(a)
a.ContextMenus = newContextMenuManager(a)
a.KeyBindings = newKeyBindingManager(a)
a.Window = newWindowManager(a)
a.ContextMenu = newContextMenuManager(a)
a.KeyBinding = newKeyBindingManager(a)
a.Browser = newBrowserManager(a)
a.Env = newEnvironmentManager(a)
a.Dialogs = newDialogManager(a)
a.Events = newEventManager(a)
a.Menus = newMenuManager(a)
a.Screens = newScreenManager(a)
a.Dialog = newDialogManager(a)
a.Event = newEventManager(a)
a.Menu = newMenuManager(a)
a.Screen = newScreenManager(a)
a.Clipboard = newClipboardManager(a)
a.SystemTray = newSystemTrayManager(a)
}
@ -524,7 +524,7 @@ func (a *App) Run() error {
go func() {
for {
event := <-applicationEvents
go a.Events.handleApplicationEvent(event)
go a.Event.handleApplicationEvent(event)
}
}()
go func() {
@ -561,7 +561,7 @@ func (a *App) Run() error {
go func() {
for {
menuItemID := <-menuItemClicked
go a.Menus.handleMenuItemClicked(menuItemID)
go a.Menu.handleMenuItemClicked(menuItemID)
}
}()

View file

@ -235,7 +235,7 @@ func (m *macosApp) run() error {
C.startSingleInstanceListener(cUniqueID)
}
// Add a hook to the ApplicationDidFinishLaunching event
m.parent.Events.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(*ApplicationEvent) {
m.parent.Event.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(*ApplicationEvent) {
C.setApplicationShouldTerminateAfterLastWindowClosed(C.bool(m.parent.options.Mac.ApplicationShouldTerminateAfterLastWindowClosed))
C.setActivationPolicy(C.int(m.parent.options.Mac.ActivationPolicy))
C.activateIgnoringOtherApps()
@ -318,7 +318,7 @@ func processURLRequest(windowID C.uint, wkUrlSchemeTask unsafe.Pointer) {
Request: webview.NewRequest(wkUrlSchemeTask),
windowId: uint(windowID),
windowName: func() string {
if window, ok := globalApplication.Windows.GetByID(uint(windowID)); ok {
if window, ok := globalApplication.Window.GetByID(uint(windowID)); ok {
return window.Name()
}
return ""

View file

@ -94,7 +94,7 @@ func (a *linuxApp) setApplicationMenu(menu *Menu) {
func (a *linuxApp) run() error {
a.parent.Events.OnApplicationEvent(events.Linux.ApplicationStartup, func(evt *ApplicationEvent) {
a.parent.Event.OnApplicationEvent(events.Linux.ApplicationStartup, func(evt *ApplicationEvent) {
// TODO: What should happen here?
})
a.setupCommonEvents()

View file

@ -1,7 +1,7 @@
package application
func (a *linuxApp) showAboutDialog(title string, message string, icon []byte) {
window, _ := globalApplication.Windows.GetByID(a.getCurrentWindowID())
window, _ := globalApplication.Window.GetByID(a.getCurrentWindowID())
var parent uintptr
if window != nil {
parent, _ = window.(*WebviewWindow).NativeWindowHandle()
@ -24,7 +24,7 @@ type linuxDialog struct {
func (m *linuxDialog) show() {
windowId := getNativeApplication().getCurrentWindowID()
window, _ := globalApplication.Windows.GetByID(windowId)
window, _ := globalApplication.Window.GetByID(windowId)
var parent uintptr
if window != nil {
parent, _ = window.(*WebviewWindow).NativeWindowHandle()

View file

@ -13,7 +13,7 @@ func (m *macosApp) setupCommonEvents() {
for sourceEvent, targetEvent := range commonApplicationEventMap {
sourceEvent := sourceEvent
targetEvent := targetEvent
m.parent.Events.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
m.parent.Event.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
event.Id = uint(targetEvent)
applicationEvents <- event
})

View file

@ -13,7 +13,7 @@ func (a *linuxApp) setupCommonEvents() {
for sourceEvent, targetEvent := range commonApplicationEventMap {
sourceEvent := sourceEvent
targetEvent := targetEvent
a.parent.Events.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
a.parent.Event.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
event.Id = uint(targetEvent)
applicationEvents <- event
})

View file

@ -13,7 +13,7 @@ func (m *windowsApp) setupCommonEvents() {
for sourceEvent, targetEvent := range commonApplicationEventMap {
sourceEvent := sourceEvent
targetEvent := targetEvent
m.parent.Events.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
m.parent.Event.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
event.Id = uint(targetEvent)
applicationEvents <- event
})

View file

@ -54,7 +54,7 @@ func TestServiceShutdown(t *testing.T) {
app.RegisterService(services[5])
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Quit()
})

View file

@ -81,7 +81,7 @@ func TestServiceShutdownError(t *testing.T) {
app.RegisterService(services[5])
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Quit()
})

View file

@ -64,7 +64,7 @@ func TestServiceStartup(t *testing.T) {
app.RegisterService(services[5])
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Quit()
})

View file

@ -55,7 +55,7 @@ func TestServiceStartupError(t *testing.T) {
app.RegisterService(services[5])
app.Events.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
t.Errorf("Application started")
app.Quit()
})

Some files were not shown because too many files have changed in this diff Show more