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

Feature/keyboard handling #495

Closed
wants to merge 4 commits into from
Closed

Feature/keyboard handling #495

wants to merge 4 commits into from

Conversation

dmweis
Copy link

@dmweis dmweis commented Aug 24, 2020

Hey!
I am using Iced for a small applicaiton and I wanted to add the abaility to exit by pressing Escape.
But it seems that there isn't a straight forward way to subscribe to keyboard events as far as I can tell.

There is a way to do it in PaneGrids but the handling is a bit more complicated and it seems you can't handle different combinations of moddifiers (For example handle ctrl + d differently from alt + d)

I've implemented a small keyboard handler for container and I updated the stopwatch exmaple to show it I would use this.
If this is something you like, I'd be interested in extending it to other widgets or including mouse events.

Also Iced is really cool!

@dmweis
Copy link
Author

dmweis commented Aug 24, 2020

Hmmm. I just found out that I could have solved this using a subscription.
It doesn't offer the abaility to bubble events as far as I can tell. But it would be enough for my needs

@hecrj
Copy link
Member

hecrj commented Aug 24, 2020

Thanks!

I think we need to be careful with adding too much functionality to simple widgets. In this case, I believe a better approach would be to create a new widget extending a Container by using composition.

But as you mention, using a Subscription is the recommended way to go until some kind of event capturing/bubbling lands. It is not completely clear yet how this feature will shape up. Therefore, we should probably wait until then before introducing more logic that could conflict with it.

There are a bunch of related issues and discussions that we should keep in mind:

@hecrj hecrj closed this Aug 24, 2020
@hecrj hecrj added the feature New feature or request label Aug 24, 2020
@hecrj hecrj added this to the 0.2.0 milestone Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants