Close dialog on esc if text input is focused
Closes: pop-os/cosmic-edit#350 Escape unfocusses the main text input widget instead of closing the dialog. The user has to hit escape twice to close the window. It's not a big deal, but it's also unexpected and unergonomic.
This commit is contained in:
parent
90d705dd52
commit
1a465ffd7a
1 changed files with 11 additions and 2 deletions
|
|
@ -13,11 +13,12 @@ use cosmic::{
|
|||
keyboard::{Event as KeyEvent, Key, Modifiers},
|
||||
stream, window,
|
||||
},
|
||||
iced_core::widget::operation,
|
||||
theme,
|
||||
widget::{
|
||||
self,
|
||||
menu::{Action as MenuAction, KeyBind, key_bind::Modifier},
|
||||
segmented_button,
|
||||
menu::{key_bind::Modifier, Action as MenuAction, KeyBind},
|
||||
segmented_button, Operation,
|
||||
},
|
||||
};
|
||||
use notify_debouncer_full::{
|
||||
|
|
@ -1271,6 +1272,14 @@ impl Application for App {
|
|||
return Task::none();
|
||||
}
|
||||
|
||||
// Close the dialog if the focused widget is the dialog's main text input instead of
|
||||
// unfocussing the widget.
|
||||
if let operation::Outcome::Some(focused) = operation::focusable::find_focused().finish() {
|
||||
if self.dialog_text_input == focused {
|
||||
return self.update(Message::Cancel);
|
||||
}
|
||||
}
|
||||
|
||||
self.update(Message::Cancel)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue