+15
-1
src/main.rs
+15
-1
src/main.rs
···
9
9
use tokio::sync::{OnceCell, mpsc};
10
10
use winit::{
11
11
application::ApplicationHandler,
12
-
event::{ElementState, MouseButton, WindowEvent},
12
+
event::{ElementState, MouseButton, TouchPhase, WindowEvent},
13
13
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
14
14
window::{Window, WindowAttributes, WindowId},
15
15
};
···
473
473
event_loop.exit();
474
474
return;
475
475
}
476
+
WindowEvent::Touch(touch) => {
477
+
let pos = (touch.location.x as f32, touch.location.y as f32);
478
+
match touch.phase {
479
+
TouchPhase::Started => {
480
+
self.handle_mouse_press(pos);
481
+
}
482
+
TouchPhase::Moved => {
483
+
self.handle_mouse_move(pos);
484
+
}
485
+
TouchPhase::Ended | TouchPhase::Cancelled => {
486
+
self.handle_mouse_release();
487
+
}
488
+
}
489
+
}
476
490
WindowEvent::MouseInput { state, button, .. } => {
477
491
if button == MouseButton::Left {
478
492
match state {