Clear pending keystrokes when an action is dispatched
This commit is contained in:
parent
4f6bef5b63
commit
5747c9b7a1
3 changed files with 17 additions and 5 deletions
|
@ -103,6 +103,8 @@ impl DispatchTree {
|
||||||
.keystroke_matchers
|
.keystroke_matchers
|
||||||
.remove_entry(self.context_stack.as_slice())
|
.remove_entry(self.context_stack.as_slice())
|
||||||
{
|
{
|
||||||
|
dbg!("preserve matcher", matcher.has_pending_keystrokes());
|
||||||
|
|
||||||
self.keystroke_matchers.insert(context_stack, matcher);
|
self.keystroke_matchers.insert(context_stack, matcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,6 @@ impl KeystrokeMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!("replace with a function that calls an FnMut for every binding matching the action")
|
|
||||||
// pub fn bindings_for_action(&self, action_id: TypeId) -> impl Iterator<Item = &Binding> {
|
|
||||||
// self.keymap.lock().bindings_for_action(action_id)
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn clear_pending(&mut self) {
|
pub fn clear_pending(&mut self) {
|
||||||
self.pending_keystrokes.clear();
|
self.pending_keystrokes.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -572,6 +572,17 @@ impl<'a> WindowContext<'a> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn clear_pending_keystrokes(&mut self) {
|
||||||
|
self.window
|
||||||
|
.rendered_frame
|
||||||
|
.dispatch_tree
|
||||||
|
.clear_pending_keystrokes();
|
||||||
|
self.window
|
||||||
|
.next_frame
|
||||||
|
.dispatch_tree
|
||||||
|
.clear_pending_keystrokes();
|
||||||
|
}
|
||||||
|
|
||||||
/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
|
/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
|
||||||
/// that are currently on the stack to be returned to the app.
|
/// that are currently on the stack to be returned to the app.
|
||||||
pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext) + 'static) {
|
pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext) + 'static) {
|
||||||
|
@ -1626,6 +1637,10 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !actions.is_empty() {
|
||||||
|
self.clear_pending_keystrokes();
|
||||||
|
}
|
||||||
|
|
||||||
for action in actions {
|
for action in actions {
|
||||||
self.dispatch_action_on_node(node_id, action.boxed_clone());
|
self.dispatch_action_on_node(node_id, action.boxed_clone());
|
||||||
if !self.propagate_event {
|
if !self.propagate_event {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue