iced-yoda/src/input/mouse/button.rs

33 lines
918 B
Rust
Raw Normal View History

2019-08-29 01:35:37 +02:00
/// The button of a mouse.
2019-09-05 09:59:38 +02:00
///
/// If you are using [`winit`], consider enabling the `winit` feature to get
/// conversion implementations for free!
///
/// [`winit`]: https://docs.rs/winit/0.20.0-alpha3/winit/
2019-07-20 19:12:31 +02:00
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum Button {
2019-08-29 01:35:37 +02:00
/// The left mouse button.
2019-07-20 19:12:31 +02:00
Left,
2019-08-29 01:35:37 +02:00
/// The right mouse button.
2019-07-20 19:12:31 +02:00
Right,
2019-08-29 01:35:37 +02:00
/// The middle (wheel) button.
2019-07-20 19:12:31 +02:00
Middle,
2019-08-29 01:35:37 +02:00
/// Some other button.
2019-07-20 19:12:31 +02:00
Other(u8),
}
#[cfg(feature = "winit")]
impl From<winit::event::MouseButton> for super::Button {
fn from(mouse_button: winit::event::MouseButton) -> Self {
match mouse_button {
winit::event::MouseButton::Left => Button::Left,
winit::event::MouseButton::Right => Button::Right,
winit::event::MouseButton::Middle => Button::Middle,
winit::event::MouseButton::Other(other) => Button::Other(other),
}
}
}