Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture Key Events #173

Closed
cryptoquick opened this issue Jan 30, 2020 · 7 comments
Closed

Capture Key Events #173

cryptoquick opened this issue Jan 30, 2020 · 7 comments
Labels
question Further information is requested
Milestone

Comments

@cryptoquick
Copy link

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.

@hecrj
Copy link
Member

hecrj commented Jan 30, 2020

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.

@hecrj hecrj added the question Further information is requested label Jan 30, 2020
@hecrj hecrj added this to the 0.1.0 milestone Jan 30, 2020
@cryptoquick
Copy link
Author

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?

@hecrj
Copy link
Member

hecrj commented Feb 4, 2020

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.

@cryptoquick
Copy link
Author

Wow, that'd be really great! For now I'll try to use the approach you mentioned earlier.

@hecrj hecrj modified the milestones: 0.1.0, 0.2.0 Apr 2, 2020
@abreis
Copy link

abreis commented Jun 24, 2020

Note though, that for Cmd-Q on macOS, the events subscription doesn't intercept the key combination and the app is still forcefully terminated.

#170 is probably the solution for this, as well as to have a way to gracefully quit the Application as proposed in #170 (comment).

@hecrj
Copy link
Member

hecrj commented Aug 12, 2020

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.

@cryptoquick
Copy link
Author

@hecrj Yeah, I had tested this on the other PR, this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants