mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:40:54 +00:00
Allow context menu to be cancelled after deploying it twice
Previously, two right clicks would cause an issue with cancelling the context menu via escape.
This commit is contained in:
parent
c3baf2748f
commit
9909fc529b
2 changed files with 7 additions and 1 deletions
|
@ -169,7 +169,9 @@ impl ContextMenu {
|
|||
self.items = items.collect();
|
||||
self.position = position;
|
||||
self.visible = true;
|
||||
self.previously_focused_view_id = cx.focused_view_id(cx.window_id());
|
||||
if !cx.is_self_focused() {
|
||||
self.previously_focused_view_id = cx.focused_view_id(cx.window_id());
|
||||
}
|
||||
cx.focus_self();
|
||||
} else {
|
||||
self.visible = false;
|
||||
|
|
|
@ -3255,6 +3255,10 @@ impl<'a, T: View> ViewContext<'a, T> {
|
|||
self.app.focus(self.window_id, Some(self.view_id));
|
||||
}
|
||||
|
||||
pub fn is_self_focused(&self) -> bool {
|
||||
self.app.focused_view_id(self.window_id) == Some(self.view_id)
|
||||
}
|
||||
|
||||
pub fn blur(&mut self) {
|
||||
self.app.focus(self.window_id, None);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue