-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for tracking modifierFlags on key events (#138)
* add support for getting modifierFlags to track which modifier keys are currently pressed with the ability to differentiate left vs. right * add custom display format for EventModifierBitFlag, printing key symbols
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#[cfg(test)] | ||
mod event_test { | ||
use crate::appkit::EventModifierBitFlag; | ||
#[test] | ||
fn test_event_modifier_bit_flag_display() { | ||
assert_eq!("‹⇧" , format!("{}",EventModifierBitFlag::LeftShift)); | ||
assert_eq!("‹⇧›" , format!("{}",EventModifierBitFlag::Shift)); | ||
assert_eq!("⇧›" , format!("{}",EventModifierBitFlag::RightShift)); | ||
assert_eq!("‹⇧‹⌃‹⌥‹⌘" , format!("{}",EventModifierBitFlag::LeftModi)); | ||
assert_eq!("⇧›⌃›⌥›⌘›" , format!("{}",EventModifierBitFlag::RightModi)); | ||
assert_eq!("‹⇧›‹⌃›‹⌥›‹⌘›" , format!("{}",EventModifierBitFlag::LRModi)); | ||
assert_eq!("🌐" , format!("{:#}",EventModifierBitFlag::Function)); // when it's a modifier key | ||
assert_eq!("ƒ" , format!("{}",EventModifierBitFlag::Function)); | ||
assert_eq!("⇭" , format!("{:#}",EventModifierBitFlag::Numpad)); // when it's a modifier key | ||
assert_eq!("🔢" , format!("{}",EventModifierBitFlag::Numpad)); | ||
assert_eq!("ℹ" , format!("{}",EventModifierBitFlag::Help)); | ||
assert_eq!("!🖮" , format!("{}",EventModifierBitFlag::DeviceIndependentFlagsMask)); | ||
// Shift ignored, only flagmask remains | ||
assert_eq!("!🖮" , format!("{}",EventModifierBitFlag::DeviceIndependentFlagsMask | EventModifierBitFlag::RightShift)); | ||
} | ||
} |