On Web, implement DeviceEvents (#2871)

This commit is contained in:
daxpedda 2023-06-14 10:26:26 +02:00 committed by GitHub
parent 9a9c9b15ba
commit 6300cf915e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 405 additions and 85 deletions

View file

@ -12,6 +12,8 @@ use crate::window::{WindowAttributes, WindowId as RootWindowId};
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use js_sys::Promise;
use smol_str::SmolStr;
@ -24,6 +26,7 @@ use web_sys::{Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, WheelEvent};
pub struct Canvas {
common: Common,
id: WindowId,
pub has_focus: Arc<AtomicBool>,
on_touch_start: Option<EventListenerHandle<dyn FnMut(Event)>>,
on_touch_end: Option<EventListenerHandle<dyn FnMut(Event)>>,
on_focus: Option<EventListenerHandle<dyn FnMut(FocusEvent)>>,
@ -91,6 +94,7 @@ impl Canvas {
wants_fullscreen: Rc::new(RefCell::new(false)),
},
id,
has_focus: Arc::new(AtomicBool::new(false)),
on_touch_start: None,
on_touch_end: None,
on_blur: None,