summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/checkbox/README.md2
-rw-r--r--examples/todos/src/main.rs21
2 files changed, 21 insertions, 2 deletions
diff --git a/examples/checkbox/README.md b/examples/checkbox/README.md
index b7f85684..76e6764c 100644
--- a/examples/checkbox/README.md
+++ b/examples/checkbox/README.md
@@ -6,7 +6,7 @@ The __[`main`]__ file contains all the code of the example.
You can run it with `cargo run`:
```
-cargo run --package pick_list
+cargo run --package checkbox
```
[`main`]: src/main.rs
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 6408f09c..6a87f58c 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -1,6 +1,6 @@
use iced::alignment::{self, Alignment};
use iced::event::{self, Event};
-use iced::keyboard;
+use iced::keyboard::{self, KeyCode, Modifiers};
use iced::subscription;
use iced::theme::{self, Theme};
use iced::widget::{
@@ -50,6 +50,7 @@ enum Message {
FilterChanged(Filter),
TaskMessage(usize, TaskMessage),
TabPressed { shift: bool },
+ ToggleFullscreen(window::Mode),
}
impl Application for Todos {
@@ -156,6 +157,9 @@ impl Application for Todos {
widget::focus_next()
}
}
+ Message::ToggleFullscreen(mode) => {
+ window::change_mode(mode)
+ }
_ => Command::none(),
};
@@ -266,6 +270,21 @@ impl Application for Todos {
) => Some(Message::TabPressed {
shift: modifiers.shift(),
}),
+ (
+ Event::Keyboard(keyboard::Event::KeyPressed {
+ key_code,
+ modifiers: Modifiers::SHIFT,
+ }),
+ event::Status::Ignored,
+ ) => match key_code {
+ KeyCode::Up => {
+ Some(Message::ToggleFullscreen(window::Mode::Fullscreen))
+ }
+ KeyCode::Down => {
+ Some(Message::ToggleFullscreen(window::Mode::Windowed))
+ }
+ _ => None,
+ },
_ => None,
})
}