On Web, implement DeviceEvents (#2871)
This commit is contained in:
parent
9a9c9b15ba
commit
6300cf915e
8 changed files with 405 additions and 85 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue