Turn Touch into a touch::Event enum

This commit is contained in:
Héctor Ramón Jiménez 2020-12-15 06:38:46 +01:00
parent 09110a93b0
commit 3bdf931925
9 changed files with 89 additions and 118 deletions

View file

@ -4,7 +4,7 @@
use crate::event::{self, Event};
use crate::layout;
use crate::mouse;
use crate::touch::{self, Touch};
use crate::touch;
use crate::{
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Widget,
};
@ -166,10 +166,7 @@ where
) -> event::Status {
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| Event::Touch(Touch {
phase: touch::Phase::Started,
..
}) => {
| Event::Touch(touch::Event::FingerPressed { .. }) => {
if self.on_press.is_some() {
let bounds = layout.bounds();
@ -181,10 +178,7 @@ where
}
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(Touch {
phase: touch::Phase::Ended,
..
}) => {
| Event::Touch(touch::Event::FingerLifted { .. }) => {
if let Some(on_press) = self.on_press.clone() {
let bounds = layout.bounds();
@ -199,10 +193,7 @@ where
}
}
}
Event::Touch(Touch {
phase: touch::Phase::Canceled,
..
}) => {
Event::Touch(touch::Event::FingerLost { .. }) => {
self.state.is_pressed = false;
}
_ => {}