Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
OussamaM1 opened this issue Mar 15, 2025 · 0 comments
Open
2 tasks done

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

OussamaM1 opened this issue Mar 15, 2025 · 0 comments
Labels
Documentation Improvements or additions to documentation

Comments

@OussamaM1
Copy link

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.
@OussamaM1 OussamaM1 added the Documentation Improvements or additions to documentation label Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant