mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-01 05:15:19 +03:00
Always dismiss context menu on click
This commit is contained in:
parent
5e8b7bd06d
commit
1b5e79251c
@ -126,7 +126,6 @@ pub struct ContextMenu {
|
|||||||
selected_index: Option<usize>,
|
selected_index: Option<usize>,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
previously_focused_view_id: Option<usize>,
|
previously_focused_view_id: Option<usize>,
|
||||||
clicked: bool,
|
|
||||||
parent_view_id: usize,
|
parent_view_id: usize,
|
||||||
_actions_observation: Subscription,
|
_actions_observation: Subscription,
|
||||||
}
|
}
|
||||||
@ -187,7 +186,6 @@ impl ContextMenu {
|
|||||||
selected_index: Default::default(),
|
selected_index: Default::default(),
|
||||||
visible: Default::default(),
|
visible: Default::default(),
|
||||||
previously_focused_view_id: Default::default(),
|
previously_focused_view_id: Default::default(),
|
||||||
clicked: false,
|
|
||||||
parent_view_id,
|
parent_view_id,
|
||||||
_actions_observation: cx.observe_actions(Self::action_dispatched),
|
_actions_observation: cx.observe_actions(Self::action_dispatched),
|
||||||
}
|
}
|
||||||
@ -203,18 +201,14 @@ impl ContextMenu {
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|item| item.action_id() == Some(action_id))
|
.position(|item| item.action_id() == Some(action_id))
|
||||||
{
|
{
|
||||||
if self.clicked {
|
self.selected_index = Some(ix);
|
||||||
self.cancel(&Default::default(), cx);
|
cx.notify();
|
||||||
} else {
|
cx.spawn(|this, mut cx| async move {
|
||||||
self.selected_index = Some(ix);
|
cx.background().timer(Duration::from_millis(50)).await;
|
||||||
cx.notify();
|
this.update(&mut cx, |this, cx| this.cancel(&Default::default(), cx))?;
|
||||||
cx.spawn(|this, mut cx| async move {
|
anyhow::Ok(())
|
||||||
cx.background().timer(Duration::from_millis(50)).await;
|
})
|
||||||
this.update(&mut cx, |this, cx| this.cancel(&Default::default(), cx))?;
|
.detach_and_log_err(cx);
|
||||||
anyhow::Ok(())
|
|
||||||
})
|
|
||||||
.detach_and_log_err(cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +248,6 @@ impl ContextMenu {
|
|||||||
self.items.clear();
|
self.items.clear();
|
||||||
self.visible = false;
|
self.visible = false;
|
||||||
self.selected_index.take();
|
self.selected_index.take();
|
||||||
self.clicked = false;
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +447,7 @@ impl ContextMenu {
|
|||||||
.on_up(MouseButton::Left, |_, _, _| {}) // Capture these events
|
.on_up(MouseButton::Left, |_, _, _| {}) // Capture these events
|
||||||
.on_down(MouseButton::Left, |_, _, _| {}) // Capture these events
|
.on_down(MouseButton::Left, |_, _, _| {}) // Capture these events
|
||||||
.on_click(MouseButton::Left, move |_, menu, cx| {
|
.on_click(MouseButton::Left, move |_, menu, cx| {
|
||||||
menu.clicked = true;
|
menu.cancel(&Default::default(), cx);
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
match &action {
|
match &action {
|
||||||
ContextMenuItemAction::Action(action) => {
|
ContextMenuItemAction::Action(action) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user