-
Notifications
You must be signed in to change notification settings - Fork 922
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
Merge KeyEventExtra
into KeyEvent
#4029
base: master
Are you sure you want to change the base?
Conversation
To make the fields easier to use, and to allow constructing KeyEvent in user test code.
/// - **Android:** Unimplemented, this field is always the same value as `logical_key`. | ||
/// - **iOS:** Unimplemented, this field is always the same value as `logical_key`. | ||
/// - **Web:** Unsupported, this field is always the same value as `logical_key`. | ||
pub key_without_modifiers: keyboard::Key, |
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.
Another option would be to make this an Option<keyboard::Key>
, I'm not familiar enough with it to say what would be best.
/// - **Android:** Unimplemented, this field is always the same value as `text`. | ||
/// - **iOS:** Unimplemented, this field is always the same value as `text`. | ||
/// - **Web:** Unsupported, this field is always the same value as `text`. |
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.
Another option would be to always set None
here on these platforms, but I felt this choice was more consistent with key_without_modifiers
(unless we change that to be an Option
).
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 have it the same way as before in a struct on a KeyboardEvent
which you can not match, but can e.g. default init or set separately?
I don't really want to have an option to match on those, since they are not cross platform. Other than that removing the extension is fine and it's not that big of a breaking change.
Hmm, I can, but I kinda feel like that'd just be unnecessary indirection? And I guess it we really want users to be able to test their crates, they'll need the ability to set the fields in this extra struct anyhow?
Am I understanding correctly that your worry is that users may be more aware of a method not being cross-platform, as opposed to a field being so? |
Yes, so it's an |
To make the
text_with_all_modifiers
andkey_without_modifiers
fields easier to use, and to allow constructingKeyEvent
in user test code. This also removes the need forKeyEventExtModifierSupplement
.Fixes #3606 (which is desired by Xilem/Masonry).
I went with adding the fields on all platforms, and just defining their behaviour as the same as
text
/logical_key
on the unsupported platforms. This is similar to how we have allWindowEvent
s available on all the platforms, but not all are emitted by all of them, so I felt this was a good trade-off.changelog
module if knowledge of this change could be valuable to users