-
Notifications
You must be signed in to change notification settings - Fork 921
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
Open
madsmtm
wants to merge
1
commit into
master
Choose a base branch
from
madsmtm/key-event-extra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -49,7 +49,6 @@ use crate::dpi::{PhysicalPosition, PhysicalSize}; | |
use crate::error::RequestError; | ||
use crate::event_loop::AsyncRequestSerial; | ||
use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState}; | ||
use crate::platform_impl; | ||
#[cfg(doc)] | ||
use crate::window::Window; | ||
use crate::window::{ActivationToken, Theme, WindowId}; | ||
|
@@ -764,12 +763,6 @@ pub struct KeyEvent { | |
/// you somehow see this in the wild, we'd like to know :) | ||
pub physical_key: keyboard::PhysicalKey, | ||
|
||
// Allowing `broken_intra_doc_links` for `logical_key`, because | ||
// `key_without_modifiers` is not available on all platforms | ||
#[cfg_attr( | ||
not(any(windows_platform, macos_platform, x11_platform, wayland_platform)), | ||
allow(rustdoc::broken_intra_doc_links) | ||
)] | ||
/// This value is affected by all modifiers except <kbd>Ctrl</kbd>. | ||
/// | ||
/// This has two use cases: | ||
|
@@ -785,7 +778,7 @@ pub struct KeyEvent { | |
/// - **Web:** Dead keys might be reported as the real key instead of `Dead` depending on the | ||
/// browser/OS. | ||
/// | ||
/// [`key_without_modifiers`]: crate::platform::modifier_supplement::KeyEventExtModifierSupplement::key_without_modifiers | ||
/// [`key_without_modifiers`]: Self::key_without_modifiers | ||
pub logical_key: keyboard::Key, | ||
|
||
/// Contains the text produced by this keypress. | ||
|
@@ -806,7 +799,7 @@ pub struct KeyEvent { | |
/// This is `None` if the current keypress cannot | ||
/// be interpreted as text. | ||
/// | ||
/// See also: `text_with_all_modifiers()` | ||
/// See also [`text_with_all_modifiers`][Self::text_with_all_modifiers]. | ||
pub text: Option<SmolStr>, | ||
|
||
/// Contains the location of this key on the keyboard. | ||
|
@@ -862,13 +855,33 @@ pub struct KeyEvent { | |
/// ``` | ||
pub repeat: bool, | ||
|
||
/// Platform-specific key event information. | ||
/// Identical to [`text`][Self::text] but this is affected by <kbd>Ctrl</kbd>. | ||
/// | ||
/// For example, pressing <kbd>Ctrl</kbd>+<kbd>a</kbd> produces `Some("\x01")`. | ||
/// | ||
/// ## Platform-specific | ||
/// | ||
/// - **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`. | ||
pub text_with_all_modifiers: Option<SmolStr>, | ||
|
||
/// This value ignores all modifiers including, but not limited to <kbd>Shift</kbd>, | ||
/// <kbd>Caps Lock</kbd>, and <kbd>Ctrl</kbd>. In most cases this means that the | ||
/// unicode character in the resulting string is lowercase. | ||
/// | ||
/// This is useful for key-bindings / shortcut key combinations. | ||
/// | ||
/// On Windows, Linux and macOS, this type contains the key without modifiers and the text with | ||
/// all modifiers applied. | ||
/// In case [`logical_key`][Self::logical_key] reports [`Dead`][keyboard::Key::Dead], | ||
/// this will still report the key as `Character` according to the current keyboard | ||
/// layout. This value cannot be `Dead`. | ||
/// | ||
/// ## Platform-specific | ||
/// | ||
/// On Android, iOS, Redox and Web, this type is a no-op. | ||
pub(crate) platform_specific: platform_impl::KeyEventExtra, | ||
/// - **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 commentThe reason will be displayed to describe this comment to others. Learn more. Another option would be to make this an |
||
} | ||
|
||
/// Describes keyboard modifiers event. | ||
|
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 was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withkey_without_modifiers
(unless we change that to be anOption
).