mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-12 19:11:23 +03:00
Emit Focus
events from Pane
only when it didn't have focus before
This commit is contained in:
parent
e7c14dacae
commit
5768f14a03
@ -159,6 +159,7 @@ pub struct Pane {
|
||||
items: Vec<Box<dyn ItemHandle>>,
|
||||
activation_history: Vec<EntityId>,
|
||||
zoomed: bool,
|
||||
was_focused: bool,
|
||||
active_item_index: usize,
|
||||
last_focused_view_by_item: HashMap<EntityId, FocusHandle>,
|
||||
autoscroll: bool,
|
||||
@ -317,6 +318,7 @@ impl Pane {
|
||||
focus_handle: cx.focus_handle(),
|
||||
items: Vec::new(),
|
||||
activation_history: Vec::new(),
|
||||
was_focused: false,
|
||||
zoomed: false,
|
||||
active_item_index: 0,
|
||||
last_focused_view_by_item: Default::default(),
|
||||
@ -413,7 +415,8 @@ impl Pane {
|
||||
}
|
||||
|
||||
fn focus_in(&mut self, cx: &mut ViewContext<Self>) {
|
||||
if !self.has_focus(cx) {
|
||||
if !self.was_focused {
|
||||
self.was_focused = true;
|
||||
cx.emit(Event::Focus);
|
||||
cx.notify();
|
||||
}
|
||||
@ -444,6 +447,7 @@ impl Pane {
|
||||
}
|
||||
|
||||
fn focus_out(&mut self, cx: &mut ViewContext<Self>) {
|
||||
self.was_focused = false;
|
||||
self.toolbar.update(cx, |toolbar, cx| {
|
||||
toolbar.focus_changed(false, cx);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user