Update bitflags to 2.0
Co-authored-by: dAxpeDDa <daxpedda@gmail.com>
This commit is contained in:
parent
d273518ce9
commit
31ebc5caf4
14 changed files with 27 additions and 14 deletions
|
|
@ -7,6 +7,7 @@ use std::convert::TryInto;
|
|||
use web_sys::{HtmlCanvasElement, KeyboardEvent, MouseEvent, PointerEvent, WheelEvent};
|
||||
|
||||
bitflags! {
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ButtonsState: u16 {
|
||||
const LEFT = 0b001;
|
||||
const RIGHT = 0b010;
|
||||
|
|
@ -31,13 +32,13 @@ impl From<MouseButton> for ButtonsState {
|
|||
MouseButton::Left => ButtonsState::LEFT,
|
||||
MouseButton::Right => ButtonsState::RIGHT,
|
||||
MouseButton::Middle => ButtonsState::MIDDLE,
|
||||
MouseButton::Other(value) => unsafe { ButtonsState::from_bits_unchecked(value) },
|
||||
MouseButton::Other(value) => ButtonsState::from_bits_retain(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mouse_buttons(event: &MouseEvent) -> ButtonsState {
|
||||
unsafe { ButtonsState::from_bits_unchecked(event.buttons()) }
|
||||
ButtonsState::from_bits_retain(event.buttons())
|
||||
}
|
||||
|
||||
pub fn mouse_button(event: &MouseEvent) -> Option<MouseButton> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue