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

@ -57,6 +57,17 @@ pub fn mouse_button(event: &MouseEvent) -> Option<MouseButton> {
}
}
impl MouseButton {
pub fn to_id(self) -> u32 {
match self {
MouseButton::Left => 0,
MouseButton::Right => 1,
MouseButton::Middle => 2,
MouseButton::Other(value) => value.into(),
}
}
}
pub fn mouse_position(event: &MouseEvent) -> LogicalPosition<f64> {
LogicalPosition {
x: event.offset_x() as f64,