Skip to content

Getting error in code example for System Tray - wails v3 #4137

Description

@OussamaM1

Have you read the Documentation Contribution Guidelines?

Description

in this section: https://v3alpha.wails.io/learn/systray/#attaching-a-window
The following code gives error in func()
Error: Cannot use 'func() { app. Quit() }' (type func()) as the type func(*Context)

app := application.New()

// Create system tray
systray := app.NewSystemTray()
systray.SetLabel("My App")

// Create a window
window := app.NewWebviewWindow()

// Attach the window to the system tray
systray.AttachWindow(window)

// Optional: Set window offset from tray icon
systray.WindowOffset(10)

// Optional: Set debounce time for window show/hide
systray.WindowDebounce(200 * time.Millisecond)

// Add a menu (optional)
menu := application.NewMenu()
menu.Add("Open").OnClick(func() {
    window.Show()
})
menu.Add("Quit").OnClick(func() {
    app.Quit()
})
systray.SetMenu(menu)

systray.Run()

Adding ctx *application.Context will fix the error

Self-service

  • I'd be willing to address this documentation request myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions