macosui / macos_ui

Flutter widgets and themes implementing the current macOS design language.
https://macosui.github.io/macos_ui/#/
MIT License
1.84k stars 177 forks source link

Expose NSWindow Callbacks for Enhanced Window Handling #469

Closed ganeshrvel closed 11 months ago

ganeshrvel commented 1 year ago

This PR proposes exposing several NSWindow event callbacks, such as onWindowDidBecomeMain, onWindowDidResignMain, onWindowDidBecomeKey, onWindowDidResignKey, onWindowDidChangeScreen, onWindowDidMove, and onWindowDidResize, to allow developers to leverage and customize window behavior better.

Pre-launch Checklist

GroovinChip commented 1 year ago

@Adrian-Samoticha what are your thoughts on this? Do we want to route more of MWU through MUI, or would you rather folks use MWU directly?

Adrian-Samoticha commented 1 year ago

@Adrian-Samoticha what are your thoughts on this? Do we want to route more of MWU through MUI, or would you rather folks use MWU directly?

Frankly, I do like this proposal. I think since we’re already routing MWU calls through MUI it probably doesn’t hurt to expand on that. However, I’d argue that we should go all the way and expose all NSWindowDelegate callbacks in that case.

Furthermore, I’d argue that using VoidCallback here isn’t ideal, since that means that you can only define a single function for each callback. I’d suggest we instead define a sort of “window event stream” which emits an enum corresponding to each NSWindowDelegate method whenever an event is triggered.

GroovinChip commented 1 year ago

I agree @Adrian-Samoticha. @ganeshrvel, can you please make the proposed changes?

GroovinChip commented 11 months ago

@ganeshrvel I am closing this due to inactivity. Please feel free to reopen when you are ready to make the requested changes.