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, Size, Widget,
};
@ -209,10 +209,7 @@ where
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| Event::Touch(Touch {
phase: touch::Phase::Started,
..
}) => {
| Event::Touch(touch::Event::FingerPressed { .. }) => {
if layout.bounds().contains(cursor_position) {
change();
self.state.is_dragging = true;
@ -221,10 +218,8 @@ where
}
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(Touch {
phase: touch::Phase::Ended,
..
}) => {
| Event::Touch(touch::Event::FingerLifted { .. })
| Event::Touch(touch::Event::FingerLost { .. }) => {
if self.state.is_dragging {
if let Some(on_release) = self.on_release.clone() {
messages.push(on_release);
@ -235,10 +230,7 @@ where
}
}
Event::Mouse(mouse::Event::CursorMoved { .. })
| Event::Touch(Touch {
phase: touch::Phase::Moved,
..
}) => {
| Event::Touch(touch::Event::FingerMoved { .. }) => {
if self.state.is_dragging {
change();