This commit is contained in:
Nathan Sobo 2022-04-05 12:09:40 -06:00
parent e2bf89b1e8
commit 41a27e6925

View File

@ -428,7 +428,7 @@ impl TestAppContext {
pub fn dispatch_action<A: Action>(&self, window_id: usize, action: A) { pub fn dispatch_action<A: Action>(&self, window_id: usize, action: A) {
let mut cx = self.cx.borrow_mut(); let mut cx = self.cx.borrow_mut();
let responder_chain = cx let dispatch_path = cx
.presenters_and_platform_windows .presenters_and_platform_windows
.get(&window_id) .get(&window_id)
.unwrap() .unwrap()
@ -436,7 +436,7 @@ impl TestAppContext {
.borrow() .borrow()
.dispatch_path(cx.as_ref()); .dispatch_path(cx.as_ref());
cx.dispatch_action_any(window_id, &responder_chain, &action); cx.dispatch_action_any(window_id, &dispatch_path, &action);
} }
pub fn dispatch_global_action<A: Action>(&self, action: A) { pub fn dispatch_global_action<A: Action>(&self, action: A) {
@ -457,9 +457,9 @@ impl TestAppContext {
.unwrap() .unwrap()
.0 .0
.clone(); .clone();
let responder_chain = presenter.borrow().dispatch_path(cx.as_ref()); let dispatch_path = presenter.borrow().dispatch_path(cx.as_ref());
if !cx.dispatch_keystroke(window_id, responder_chain, &keystroke) { if !cx.dispatch_keystroke(window_id, dispatch_path, &keystroke) {
presenter.borrow_mut().dispatch_event( presenter.borrow_mut().dispatch_event(
Event::KeyDown { Event::KeyDown {
keystroke, keystroke,
@ -1316,10 +1316,10 @@ impl MutableAppContext {
pub fn dispatch_action<A: Action>( pub fn dispatch_action<A: Action>(
&mut self, &mut self,
window_id: usize, window_id: usize,
responder_chain: Vec<usize>, dispatch_path: Vec<usize>,
action: &A, action: &A,
) { ) {
self.dispatch_action_any(window_id, &responder_chain, action); self.dispatch_action_any(window_id, &dispatch_path, action);
} }
pub(crate) fn dispatch_action_any( pub(crate) fn dispatch_action_any(
@ -1405,11 +1405,11 @@ impl MutableAppContext {
pub fn dispatch_keystroke( pub fn dispatch_keystroke(
&mut self, &mut self,
window_id: usize, window_id: usize,
responder_chain: Vec<usize>, dispatch_path: Vec<usize>,
keystroke: &Keystroke, keystroke: &Keystroke,
) -> bool { ) -> bool {
let mut context_chain = Vec::new(); let mut context_chain = Vec::new();
for view_id in &responder_chain { for view_id in &dispatch_path {
let view = self let view = self
.cx .cx
.views .views
@ -1422,13 +1422,12 @@ impl MutableAppContext {
for (i, cx) in context_chain.iter().enumerate().rev() { for (i, cx) in context_chain.iter().enumerate().rev() {
match self match self
.keystroke_matcher .keystroke_matcher
.push_keystroke(keystroke.clone(), responder_chain[i], cx) .push_keystroke(keystroke.clone(), dispatch_path[i], cx)
{ {
MatchResult::None => {} MatchResult::None => {}
MatchResult::Pending => pending = true, MatchResult::Pending => pending = true,
MatchResult::Action(action) => { MatchResult::Action(action) => {
if self.dispatch_action_any(window_id, &responder_chain[0..=i], action.as_ref()) if self.dispatch_action_any(window_id, &dispatch_path[0..=i], action.as_ref()) {
{
self.keystroke_matcher.clear_pending(); self.keystroke_matcher.clear_pending();
return true; return true;
} }