mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Push focus and fix keybindings
This commit is contained in:
parent
c537cf2a57
commit
f1957b1737
2 changed files with 31 additions and 22 deletions
|
@ -553,8 +553,12 @@
|
||||||
{
|
{
|
||||||
"context": "ChannelModal",
|
"context": "ChannelModal",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"left": "channel_modal::SelectNextControl",
|
"tab": "channel_modal::ToggleMode"
|
||||||
"right": "channel_modal::SelectNextControl",
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"context": "ChannelModal > Picker > Editor",
|
||||||
|
"bindings": {
|
||||||
"tab": "channel_modal::ToggleMode"
|
"tab": "channel_modal::ToggleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ actions!(channel_modal, [SelectNextControl, ToggleMode]);
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
Picker::<ChannelModalDelegate>::init(cx);
|
Picker::<ChannelModalDelegate>::init(cx);
|
||||||
cx.add_action(ChannelModal::toggle_mode);
|
cx.add_action(ChannelModal::toggle_mode);
|
||||||
cx.add_action(ChannelModal::select_next_control);
|
// cx.add_action(ChannelModal::select_next_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ChannelModal {
|
pub struct ChannelModal {
|
||||||
|
@ -64,6 +64,7 @@ impl ChannelModal {
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.subscribe(&picker, |_, _, e, cx| cx.emit(*e)).detach();
|
cx.subscribe(&picker, |_, _, e, cx| cx.emit(*e)).detach();
|
||||||
|
|
||||||
let has_focus = picker.read(cx).has_focus();
|
let has_focus = picker.read(cx).has_focus();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -105,29 +106,30 @@ impl ChannelModal {
|
||||||
picker.update_matches(picker.query(cx), cx);
|
picker.update_matches(picker.query(cx), cx);
|
||||||
cx.notify()
|
cx.notify()
|
||||||
});
|
});
|
||||||
|
cx.notify()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_next_control(&mut self, _: &SelectNextControl, cx: &mut ViewContext<Self>) {
|
// fn select_next_control(&mut self, _: &SelectNextControl, cx: &mut ViewContext<Self>) {
|
||||||
self.picker.update(cx, |picker, cx| {
|
// self.picker.update(cx, |picker, cx| {
|
||||||
let delegate = picker.delegate_mut();
|
// let delegate = picker.delegate_mut();
|
||||||
match delegate.mode {
|
// match delegate.mode {
|
||||||
Mode::ManageMembers => match delegate.selected_column {
|
// Mode::ManageMembers => match delegate.selected_column {
|
||||||
Some(UserColumn::Remove) => {
|
// Some(UserColumn::Remove) => {
|
||||||
delegate.selected_column = Some(UserColumn::ToggleAdmin)
|
// delegate.selected_column = Some(UserColumn::ToggleAdmin)
|
||||||
}
|
// }
|
||||||
Some(UserColumn::ToggleAdmin) => {
|
// Some(UserColumn::ToggleAdmin) => {
|
||||||
delegate.selected_column = Some(UserColumn::Remove)
|
// delegate.selected_column = Some(UserColumn::Remove)
|
||||||
}
|
// }
|
||||||
None => todo!(),
|
// None => todo!(),
|
||||||
},
|
// },
|
||||||
Mode::InviteMembers => {}
|
// Mode::InviteMembers => {}
|
||||||
}
|
// }
|
||||||
cx.notify()
|
// cx.notify()
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Entity for ChannelModal {
|
impl Entity for ChannelModal {
|
||||||
|
@ -209,8 +211,11 @@ impl View for ChannelModal {
|
||||||
.into_any()
|
.into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_in(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext<Self>) {
|
fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||||
self.has_focus = true;
|
self.has_focus = true;
|
||||||
|
if cx.is_self_focused() {
|
||||||
|
cx.focus(&self.picker)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_out(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext<Self>) {
|
fn focus_out(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext<Self>) {
|
||||||
|
|
Loading…
Reference in a new issue