Working multitouch example

This commit is contained in:
Artur Sapek 2022-04-13 19:08:53 -06:00 committed by Héctor Ramón Jiménez
parent 4a3c3e2a18
commit fe17641d46
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
4 changed files with 179 additions and 0 deletions

View file

@ -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 {