From fe17641d46b47f60fc2baa68bb7a0c4e137aa628 Mon Sep 17 00:00:00 2001 From: Artur Sapek Date: Wed, 13 Apr 2022 19:08:53 -0600 Subject: Working multitouch example --- examples/game_of_life/src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'examples/game_of_life/src') diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index a2030275..971ad4d7 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,22 @@ mod grid { }; match event { + Event::Touch(touch_event) => match touch_event { + touch::Event::FingerMoved { .. } => { + let message = { + *interaction = if is_populated { + Interaction::Erasing + } else { + Interaction::Drawing + }; + + populate.or(unpopulate) + }; + + (event::Status::Captured, message) + } + _ => (event::Status::Ignored, None), + }, Event::Mouse(mouse_event) => match mouse_event { mouse::Event::ButtonPressed(button) => { let message = match button { -- cgit From 8c74464b0d608fb04a1c921b2cbb36b8bc6fc9b8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 4 Oct 2022 11:53:03 +0200 Subject: Fix `clippy` lints --- examples/game_of_life/src/main.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'examples/game_of_life/src') diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index 971ad4d7..2a8b3721 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -424,22 +424,19 @@ mod grid { }; match event { - Event::Touch(touch_event) => match touch_event { - touch::Event::FingerMoved { .. } => { - let message = { - *interaction = if is_populated { - Interaction::Erasing - } else { - Interaction::Drawing - }; - - populate.or(unpopulate) + Event::Touch(touch::Event::FingerMoved { .. }) => { + let message = { + *interaction = if is_populated { + Interaction::Erasing + } else { + Interaction::Drawing }; - (event::Status::Captured, message) - } - _ => (event::Status::Ignored, None), - }, + populate.or(unpopulate) + }; + + (event::Status::Captured, message) + } Event::Mouse(mouse_event) => match mouse_event { mouse::Event::ButtonPressed(button) => { let message = match button { -- cgit