summaryrefslogtreecommitdiffstats
path: root/examples/game_of_life/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-10-04 18:20:14 +0200
committerLibravatar GitHub <noreply@github.com>2022-10-04 18:20:14 +0200
commit2278bade55b2bcd530c8c9a30a22d5f800921e55 (patch)
tree40093c0f59136426a04effa417f74bc64359c09b /examples/game_of_life/src/main.rs
parent5f758d847f7e0de0ab7134247133c169a6132de1 (diff)
parent8c74464b0d608fb04a1c921b2cbb36b8bc6fc9b8 (diff)
downloadiced-2278bade55b2bcd530c8c9a30a22d5f800921e55.tar.gz
iced-2278bade55b2bcd530c8c9a30a22d5f800921e55.tar.bz2
iced-2278bade55b2bcd530c8c9a30a22d5f800921e55.zip
Merge pull request #1305 from artursapek/canvas-touch
Expose touch events in canvas widget
Diffstat (limited to 'examples/game_of_life/src/main.rs')
-rw-r--r--examples/game_of_life/src/main.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs
index a2030275..2a8b3721 100644
--- a/examples/game_of_life/src/main.rs
+++ b/examples/game_of_life/src/main.rs
@@ -204,6 +204,7 @@ fn view_controls<'a>(
mod grid {
use crate::Preset;
+ use iced::touch;
use iced::widget::canvas;
use iced::widget::canvas::event::{self, Event};
use iced::widget::canvas::{
@@ -423,6 +424,19 @@ mod grid {
};
match event {
+ Event::Touch(touch::Event::FingerMoved { .. }) => {
+ let message = {
+ *interaction = if is_populated {
+ Interaction::Erasing
+ } else {
+ Interaction::Drawing
+ };
+
+ populate.or(unpopulate)
+ };
+
+ (event::Status::Captured, message)
+ }
Event::Mouse(mouse_event) => match mouse_event {
mouse::Event::ButtonPressed(button) => {
let message = match button {