How to open the application by left-clicking the application icon in the tray; #4495
Replies: 2 comments
-
|
Hi @victory-zz! I'm Dosu and I’m helping the wails team. Wails v2.5.1 on Windows does not support distinguishing left-click events on the tray icon—left-click always shows the menu, and there is no built-in way to override this behavior or trigger opening the application window directly on left-click. This is a limitation of how tray events are handled in the framework and the underlying systray integration. If you need this functionality, Wails v3 introduces an OnClick handler for the tray icon, which allows you to open or toggle the application window on left-click. You can see an example of this in Wails v3 where For Wails v2.5.1, there are no documented workarounds or hooks to achieve this behavior. If left-click-to-open is essential, consider migrating to Wails v3 or exploring a custom tray implementation outside of the current Wails tray API. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
We don't have a systray for v2 only v3. Moving this to a discussion. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The right-click setting menu item has been implemented, and the corresponding functions can be realized; I encountered a problem. No matter how to implement it, it seems that the function of opening the application by left-clicking the icon cannot be realized. The left-click menu item is displayed, which does not conform to the normal operation of the tray application.
To Reproduce
func Tray() *tray {
_tray.once.Do(func() {
waitUntilReady := make(chan struct{}) // wait until menus built completely
systray.Register(func() {
// load icons
assetHelper := utils.NewEmbedFS(icons, "configs/helper/webapp/images")
var ico []byte
appLog := types.GetAppcontext().GetCtxValueAsString(types.App_app_logo)
if appLog == "" || appLog == "null" {
ico, _ = assetHelper.GetFileBytes("icon_initial.ico")
} else {
ico, _ = assetHelper.GetFileBytes("icon.ico")
}
}
Expected behaviour
I hope to realize the function of opening the application by left-clicking the application icon in the tray
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions