-
Notifications
You must be signed in to change notification settings - Fork 133
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
Stack event handlers #304
Stack event handlers #304
Conversation
src/views/decorator.rs
Outdated
@@ -96,41 +96,47 @@ pub trait Decorators: View + Sized { | |||
/// | |||
/// NOTE: View should have `.keyboard_navigable()` in order to receive keyboard events | |||
fn on_key_down( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on_key_down
and on_key_up
are already stackable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the handlers from view data and made them just work like all of the other event handlers. Is there a reason to leave it this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. They have less startup cost as they directly mutate ViewData
and don't need to send an update message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should any other events be implemented with handlers in ViewData?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move as many as possible to use ViewData.event_handlers
. Just have to be careful to not change behavior. I'd probably add a ViewData::add_event_handler
method which boxes and pushes the handler for convenience.
Keep that in a separate PR if you give it a shot.
96c7031
to
3716e0d
Compare
No description provided.