Fix project panel context menu
This commit is contained in:
parent
13bb16577c
commit
9162f299a7
2 changed files with 11 additions and 5 deletions
|
@ -1497,10 +1497,13 @@ impl<'a> WindowContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding> {
|
pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding> {
|
||||||
self.window.current_frame.dispatch_tree.bindings_for_action(
|
self.window
|
||||||
action,
|
.previous_frame
|
||||||
&self.window.current_frame.dispatch_tree.context_stack,
|
.dispatch_tree
|
||||||
)
|
.bindings_for_action(
|
||||||
|
action,
|
||||||
|
&self.window.previous_frame.dispatch_tree.context_stack,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bindings_for_action_in(
|
pub fn bindings_for_action_in(
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub struct ContextMenu {
|
||||||
items: Vec<ContextMenuItem>,
|
items: Vec<ContextMenuItem>,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
selected_index: Option<usize>,
|
selected_index: Option<usize>,
|
||||||
|
delayed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FocusableView for ContextMenu {
|
impl FocusableView for ContextMenu {
|
||||||
|
@ -46,6 +47,7 @@ impl ContextMenu {
|
||||||
items: Default::default(),
|
items: Default::default(),
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
selected_index: None,
|
selected_index: None,
|
||||||
|
delayed: false,
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
@ -165,6 +167,7 @@ impl ContextMenu {
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
self.selected_index = Some(ix);
|
self.selected_index = Some(ix);
|
||||||
|
self.delayed = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
let action = dispatched.boxed_clone();
|
let action = dispatched.boxed_clone();
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
@ -205,7 +208,7 @@ impl Render for ContextMenu {
|
||||||
.on_action(cx.listener(ContextMenu::select_prev))
|
.on_action(cx.listener(ContextMenu::select_prev))
|
||||||
.on_action(cx.listener(ContextMenu::confirm))
|
.on_action(cx.listener(ContextMenu::confirm))
|
||||||
.on_action(cx.listener(ContextMenu::cancel))
|
.on_action(cx.listener(ContextMenu::cancel))
|
||||||
.map(|mut el| {
|
.when(!self.delayed, |mut el| {
|
||||||
for item in self.items.iter() {
|
for item in self.items.iter() {
|
||||||
if let ContextMenuItem::Entry {
|
if let ContextMenuItem::Entry {
|
||||||
action: Some(action),
|
action: Some(action),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue