diff options
author | 2019-11-11 20:29:58 -0800 | |
---|---|---|
committer | 2020-03-18 11:26:53 -0700 | |
commit | e19a07d40049f40f36d879a498fab4ce63778b27 (patch) | |
tree | 6ecdcb5345f6c00c2b53ee4d93afd8585c1dda2e /winit | |
parent | 9da6ce474c2cd178ca5365d46760ba0882ce7121 (diff) | |
download | iced-e19a07d40049f40f36d879a498fab4ce63778b27.tar.gz iced-e19a07d40049f40f36d879a498fab4ce63778b27.tar.bz2 iced-e19a07d40049f40f36d879a498fab4ce63778b27.zip |
Added initial touch events to support iOS
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application.rs | 1 | ||||
-rw-r--r-- | winit/src/conversion.rs | 26 |
2 files changed, 25 insertions, 2 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 891b8f12..65bffd5b 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -310,7 +310,6 @@ pub trait Application: Sized { physical_size.width, physical_size.height, ); - resized = false; } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index b6a0b64b..2fc76c9d 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -5,7 +5,7 @@ use crate::{ input::{ keyboard::{self, KeyCode, ModifiersState}, - mouse, ButtonState, + mouse, touch, ButtonState, }, window, Event, Mode, MouseCursor, }; @@ -84,6 +84,9 @@ pub fn window_event( WindowEvent::HoveredFileCancelled => { Some(Event::Window(window::Event::FilesHoveredLeft)) } + WindowEvent::Touch(touch) => { + Some(Event::Touch(touch_event(touch))) + } _ => None, } } @@ -342,3 +345,24 @@ pub(crate) fn is_private_use_character(c: char) -> bool { _ => false, } } +pub(crate) fn touch_event(touch: winit::event::Touch) -> touch::Touch { + let location = touch.location; + match touch.phase { + winit::event::TouchPhase::Started => touch::Touch::Started { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Ended => touch::Touch::Ended { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Moved => touch::Touch::Moved { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Cancelled => touch::Touch::Cancelled { + x: location.x as f32, + y: location.y as f32, + }, + } +} |