Is there a good way to, say, capture the Command-Q key event to quit the app on MacOS?
We tried to implement this pulling in some of the core iced code into our application, but the approach was less than ideal.
In native platforms, you should be able to use the Subscription returned by iced_native::subscription::events to listen to shell events directly. The [events] example showcases this.
At some point, iced should expose cross-platform subscriptions that should work on the web too.
I'll take a look and see if I can get this to work. You added it to a milestone, so do you think there's additional work needed to be done to make this easier?
Yes. As I said, there should eventually be some built-in cross-platform subscriptions like keyboard::on_press, keyboard::on_release, window::on_resize, etc.
Wow, that'd be really great! For now I'll try to use the approach you mentioned earlier.
Note though, that for Cmd-Q on macOS, the events subscription doesn't intercept the key combination and the app is still forcefully terminated.
Application as proposed in https://github.com/hecrj/iced/issues/170#issuecomment-578807687.Note though, that for Cmd-Q on macOS, the events subscription doesn't intercept the key combination and the app is still forcefully terminated.
@abreis Correct. I introduced this change in #195.
@hecrj Yeah, I had tested this on the other PR, this issue can be closed.