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:
parent
6300cf915e
commit
4748890935
7 changed files with 67 additions and 9 deletions
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue