Merge pull request #1311 from pop-os/joshmegnauth-dialog-escape
dialog escape
This commit is contained in:
commit
419516863c
2 changed files with 256 additions and 246 deletions
479
Cargo.lock
generated
479
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -10,12 +10,13 @@ use cosmic::{
|
||||||
core::SmolStr,
|
core::SmolStr,
|
||||||
event,
|
event,
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
keyboard::{Event as KeyEvent, Key, Modifiers},
|
keyboard::{Event as KeyEvent, Key, Modifiers, key::Named},
|
||||||
stream, window,
|
stream, window,
|
||||||
},
|
},
|
||||||
|
iced_core::widget::operation,
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
self,
|
self, Operation,
|
||||||
menu::{Action as MenuAction, KeyBind, key_bind::Modifier},
|
menu::{Action as MenuAction, KeyBind, key_bind::Modifier},
|
||||||
segmented_button,
|
segmented_button,
|
||||||
},
|
},
|
||||||
|
|
@ -415,6 +416,7 @@ enum Message {
|
||||||
DialogCancel,
|
DialogCancel,
|
||||||
DialogComplete,
|
DialogComplete,
|
||||||
DialogUpdate(DialogPage),
|
DialogUpdate(DialogPage),
|
||||||
|
Escape,
|
||||||
Filename(String),
|
Filename(String),
|
||||||
Filter(usize),
|
Filter(usize),
|
||||||
Key(Modifiers, Key, Option<SmolStr>),
|
Key(Modifiers, Key, Option<SmolStr>),
|
||||||
|
|
@ -1271,6 +1273,14 @@ impl Application for App {
|
||||||
return Task::none();
|
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)
|
self.update(Message::Cancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1337,6 +1347,7 @@ impl Application for App {
|
||||||
self.dialog_pages[0] = dialog_page;
|
self.dialog_pages[0] = dialog_page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::Escape => return self.on_escape(),
|
||||||
Message::Filename(new_filename) => {
|
Message::Filename(new_filename) => {
|
||||||
// Select based on filename
|
// Select based on filename
|
||||||
self.tab.select_name(&new_filename);
|
self.tab.select_name(&new_filename);
|
||||||
|
|
@ -1968,7 +1979,13 @@ impl Application for App {
|
||||||
..
|
..
|
||||||
}) => match status {
|
}) => match status {
|
||||||
event::Status::Ignored => Some(Message::Key(modifiers, key, text)),
|
event::Status::Ignored => Some(Message::Key(modifiers, key, text)),
|
||||||
event::Status::Captured => None,
|
event::Status::Captured => {
|
||||||
|
if key == Key::Named(Named::Escape) {
|
||||||
|
Some(Message::Escape)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||||
Some(Message::ModifiersChanged(modifiers))
|
Some(Message::ModifiersChanged(modifiers))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue