wails icon indicating copy to clipboard operation
wails copied to clipboard

Is there an event to trap the hiding of the window?

Open precisionpete opened this issue 2 years ago • 3 comments

Have you read the Documentation Contribution Guidelines?

Description

I have an app that is represented by a systray icon.

The desired effect is that the wails window appears or disappears when the icon is clicked. I am also making use of HideWindowOnClose = true.

I also have a variable WindowVisible that keeps track of whether the window is visible or not. That way it knows what to do when the icon is clicked.

All works just fine until I close the windows with the X in the corner. Then the WindowVisible variable gets out of sync. A couple of clicks and it is back to normal. But I would like to fix this.

I have tried to use OnBeforeClose, but this only seems to work if HideWindowOnClose = false.

Is there an event I can trap that will allow me to update my variable when the window hides?

Self-service

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

precisionpete avatar Oct 16 '23 20:10 precisionpete

There isn't currently an event fired for v2. v3 solves this issue be simply allowing you to attach a window to the systray and it acts as you've described.

leaanthony avatar Oct 21 '23 10:10 leaanthony

https://github.com/wailsapp/wails/assets/1943904/022915c6-cfbe-499f-9627-7969dfbd0948

leaanthony avatar Oct 21 '23 10:10 leaanthony

There isn't currently an event fired for v2. v3 solves this issue be simply allowing you to attach a window to the systray and it acts as you've described.

Is there an example that references this feature in v2.

Because I don't know how long v3 will have to wait

GuridMa avatar Nov 06 '23 08:11 GuridMa