wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.04k stars 1.2k forks source link

Tracking window state #2238

Open merlindru opened 1 year ago

merlindru commented 1 year ago

Is your feature request related to a problem? Please describe.

https://github.com/wailsapp/wails/pull/1349

Describe the solution you'd like

Hi y'all! I want to track the WindowState in react, but it seems there is no event for it?

I tried EventsOn(":wails:window:maximised") like in the PR, and EventsOn(":wails:WindowIsMaximised") but neither of them fire when the WindowState changes.

On a side note: Is there any documentation for the events from the wails runtime? If not, do we need some? Where can I find these events? (CTRL+F :wails: I assume :P)

Describe alternatives you've considered

No response

Additional context

No response

leaanthony commented 1 year ago

Hey thanks for opening this. There's already some window state methods available in the runtime library but I think we could do better here. Fancy a stab at it? 😅

merlindru commented 1 year ago

Yes! @leaanthony However, I can't let my frontend know when the window state changed with what's currently available in the runtime, right?

merlindru commented 1 year ago

I want to change the state of my maximize button depending on whether the window is currently maximized or not:

Window is maximised image

Window is normal image

merlindru commented 1 year ago

This is useful not only for frameless app's title bars, but for changing layout depending on the window state. My app can't know whether it's been maximised after the initial load without polling WindowIsMaximised

oSethoum commented 1 year ago

I want to change the state of my maximize button depending on whether the window is currently maximized or not:

Window is maximised image

Window is normal image

this could easily be achieved by adding an event listener on the resize event for the window and check for the window state after and update the UI accordingly.