-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core-graphics: Add CGKeyCodes for numpad keys #712
base: main
Are you sure you want to change the base?
Conversation
core-graphics/src/event.rs
Outdated
@@ -97,6 +98,25 @@ impl KeyCode { | |||
pub const RIGHT_ARROW: CGKeyCode = 0x7C; | |||
pub const DOWN_ARROW: CGKeyCode = 0x7D; | |||
pub const UP_ARROW: CGKeyCode = 0x7E; | |||
pub const NUMPAD_0: CGKeyCode = 0x52; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the convention in original Ref?
So it should be KEYPAD_0
in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we should use the same name as the original reference. In addition, would it be possible to add all the missing key constants here and put them in the order of the original header file with comments indicating what section they came from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more constants, but I put them into new structs. Otherwise the comments would have been wrong. I also used the same names as in the original header file.
core-graphics/src/event.rs
Outdated
@@ -97,6 +98,25 @@ impl KeyCode { | |||
pub const RIGHT_ARROW: CGKeyCode = 0x7C; | |||
pub const DOWN_ARROW: CGKeyCode = 0x7D; | |||
pub const UP_ARROW: CGKeyCode = 0x7E; | |||
pub const NUMPAD_0: CGKeyCode = 0x52; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we should use the same name as the original reference. In addition, would it be possible to add all the missing key constants here and put them in the order of the original header file with comments indicating what section they came from?
b7ea7d7
to
164635f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay. Thanks for included all of the keycodes! I think that only one small set of changes is necessary here.
/// [Ref](https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.13.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h#L197-L261) | ||
#[repr(C)] | ||
pub struct ANSIKeyCode; | ||
impl KeyCode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you meant to write impl AnsiKeyCode
here? In any case, I think you can just remove the new structures and keep only KeyCode
, even though they are in separate enums in the Carbon headers, they are part of the same series of values. Separating seems unnecessary here.
The numpad keys also always have the same values