Close context menu when window loses focus
This commit is contained in:
parent
70313f6271
commit
4c522b0eee
1 changed files with 8 additions and 0 deletions
|
|
@ -352,6 +352,7 @@ pub enum Message {
|
|||
WindowClose,
|
||||
WindowCloseRequested(window::Id),
|
||||
WindowNew,
|
||||
WindowUnfocus,
|
||||
ZoomDefault(Option<Entity>),
|
||||
ZoomIn(Option<Entity>),
|
||||
ZoomOut(Option<Entity>),
|
||||
|
|
@ -3025,6 +3026,12 @@ impl Application for App {
|
|||
]);
|
||||
}
|
||||
}
|
||||
Message::WindowUnfocus => {
|
||||
let tab_entity = self.tab_model.active();
|
||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(tab_entity) {
|
||||
tab.context_menu = None;
|
||||
}
|
||||
}
|
||||
Message::WindowCloseRequested(id) => {
|
||||
self.remove_window(&id);
|
||||
}
|
||||
|
|
@ -4370,6 +4377,7 @@ impl Application for App {
|
|||
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||
Some(Message::Modifiers(modifiers))
|
||||
}
|
||||
Event::Window(WindowEvent::Unfocused) => Some(Message::WindowUnfocus),
|
||||
Event::Window(WindowEvent::CloseRequested) => Some(Message::WindowClose),
|
||||
Event::Window(WindowEvent::Opened { position: _, size }) => {
|
||||
Some(Message::Size(size))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue