summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/editor/src/main.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/editor/src/main.rs b/examples/editor/src/main.rs
index 6def2082..36d4287c 100644
--- a/examples/editor/src/main.rs
+++ b/examples/editor/src/main.rs
@@ -1,10 +1,14 @@
use iced::executor;
+use iced::keyboard;
use iced::theme::{self, Theme};
use iced::widget::{
button, column, container, horizontal_space, pick_list, row, text,
text_editor, tooltip,
};
-use iced::{Alignment, Application, Command, Element, Font, Length, Settings};
+use iced::{
+ Alignment, Application, Command, Element, Font, Length, Settings,
+ Subscription,
+};
use highlighter::Highlighter;
@@ -147,6 +151,15 @@ impl Application for Editor {
}
}
+ fn subscription(&self) -> Subscription<Message> {
+ keyboard::on_key_press(|key_code, modifiers| match key_code {
+ keyboard::KeyCode::S if modifiers.command() => {
+ Some(Message::SaveFile)
+ }
+ _ => None,
+ })
+ }
+
fn view(&self) -> Element<Message> {
let controls = row![
action(new_icon(), "New file", Some(Message::NewFile)),