mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 21:00:04 -04:00
Add MouseButton::{Back, Forward} to MouseInput
Add named variants for physical back and forward keys which could be found on some mice. The macOS bits may not work on all the hardware given that apple doesn't directly support such a thing. Co-authored-by: daxpedda <daxpedda@gmail.com>
This commit is contained in:
@@ -1027,10 +1027,14 @@ fn mouse_button(event: &NSEvent) -> MouseButton {
|
||||
// The buttonNumber property only makes sense for the mouse events:
|
||||
// NSLeftMouse.../NSRightMouse.../NSOtherMouse...
|
||||
// For the other events, it's always set to 0.
|
||||
// MacOS only defines the left, right and middle buttons, 3..=31 are left as generic buttons,
|
||||
// but 3 and 4 are very commonly used as Back and Forward by hardware vendors and applications.
|
||||
match event.buttonNumber() {
|
||||
0 => MouseButton::Left,
|
||||
1 => MouseButton::Right,
|
||||
2 => MouseButton::Middle,
|
||||
3 => MouseButton::Back,
|
||||
4 => MouseButton::Forward,
|
||||
n => MouseButton::Other(n as u16),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user