Add conversion for MouseButton in winit

This commit is contained in:
Héctor Ramón Jiménez 2019-09-02 05:10:14 +02:00
parent 6d248719f3
commit 28009bc26d
3 changed files with 184 additions and 180 deletions

View file

@ -13,3 +13,15 @@ pub enum Button {
/// Some other button.
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),
}
}
}