-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Activate shortcuts based on NumLock state #145146
Activate shortcuts based on NumLock state #145146
Conversation
ab7533a
to
f970283
Compare
f970283
to
1424fe0
Compare
@@ -430,6 +440,7 @@ class SingleActivator with Diagnosticable, MenuSerializableShortcut implements S | |||
this.shift = false, | |||
this.alt = false, | |||
this.meta = false, | |||
this.numLockPolicy = NumLockPolicy.ignored, |
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 think this can just be called numLock
, to be consistent with the other arguments.
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.
Yes, i was reluctant because other fields are boolean but it is way more elegant.
@@ -142,6 +142,16 @@ class KeySet<T extends KeyboardKey> { | |||
} | |||
} | |||
|
|||
/// Determines how the state of the NumLock key is used to accept a shortcut. | |||
enum NumLockPolicy { |
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.
Maybe call this LockPolicy
or LockState
, so that it can be used with other kinds of locks (e.g. Scroll Lock, Shift Lock, Caps Lock), if we decide that we want to add them in the future. I don't really see a huge reason to add most of them at the moment, but there are some locks on other keyboards (e.g. the Hiragana/Katakana ひらがな key on a Japanese keyboard), that we might want to add 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.
Great suggestion! And very interesting to learn about this japanese key 👍
Do you have a preference between LockPolicy
and LockState
?
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 opted for 'LockState', it sounds great to me.
d66ef12
to
0ef37cc
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.
flutter/flutter@f217fc1...d31a85b 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4cec701f4635 to d8fbcfbd799c (1 revision) (flutter/flutter#145390) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from c9fbe6bab899 to 4cec701f4635 (1 revision) (flutter/flutter#145386) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from de6b8f49b849 to c9fbe6bab899 (2 revisions) (flutter/flutter#145383) 2024-03-19 leroux_bruno@yahoo.fr Activate shortcuts based on NumLock state (flutter/flutter#145146) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 59519ceee30a to de6b8f49b849 (1 revision) (flutter/flutter#145381) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from ac8f1f233d6f to 59519ceee30a (2 revisions) (flutter/flutter#145379) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4a86b5b17c39 to ac8f1f233d6f (3 revisions) (flutter/flutter#145375) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from c0d1b0d5d43f to 4a86b5b17c39 (1 revision) (flutter/flutter#145373) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3d909f14118e to c0d1b0d5d43f (1 revision) (flutter/flutter#145371) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0ee413ee276a to 3d909f14118e (5 revisions) (flutter/flutter#145370) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 89df726bf13a to 0ee413ee276a (3 revisions) (flutter/flutter#145365) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3fde3678a357 to 89df726bf13a (1 revision) (flutter/flutter#145359) 2024-03-18 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.24.7 to 3.24.8 (flutter/flutter#145358) 2024-03-18 danny@tuppeny.com Roll pub packages + update DAP tests (flutter/flutter#145349) 2024-03-18 prasadsunny1@gmail.com Fix for issue 140372 (flutter/flutter#144947) 2024-03-18 31859944+LongCatIsLooong@users.noreply.github.com Introduce methods for computing the baseline location of a RenderBox without affecting the current layout (flutter/flutter#144655) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 016206de75bc to 3fde3678a357 (2 revisions) (flutter/flutter#145350) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 90c4d64d410f to 016206de75bc (2 revisions) (flutter/flutter#145345) 2024-03-18 32242716+ricardoamador@users.noreply.github.com Switch hot_mode_dev_cycle_linux__benchmark to run in postsubmit (flutter/flutter#145343) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9162c8309e24 to 90c4d64d410f (1 revision) (flutter/flutter#145342) 2024-03-18 15619084+vashworth@users.noreply.github.com Add --no-dds to Mac_arm64_ios version of hot_mode_dev_cycle_ios__benchmark (flutter/flutter#145335) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 89fb886a162c to 9162c8309e24 (2 revisions) (flutter/flutter#145336) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 86de0f75606f to 89fb886a162c (1 revision) (flutter/flutter#145327) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#6356) flutter/flutter@f217fc1...d31a85b 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4cec701f4635 to d8fbcfbd799c (1 revision) (flutter/flutter#145390) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from c9fbe6bab899 to 4cec701f4635 (1 revision) (flutter/flutter#145386) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from de6b8f49b849 to c9fbe6bab899 (2 revisions) (flutter/flutter#145383) 2024-03-19 leroux_bruno@yahoo.fr Activate shortcuts based on NumLock state (flutter/flutter#145146) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 59519ceee30a to de6b8f49b849 (1 revision) (flutter/flutter#145381) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from ac8f1f233d6f to 59519ceee30a (2 revisions) (flutter/flutter#145379) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4a86b5b17c39 to ac8f1f233d6f (3 revisions) (flutter/flutter#145375) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from c0d1b0d5d43f to 4a86b5b17c39 (1 revision) (flutter/flutter#145373) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3d909f14118e to c0d1b0d5d43f (1 revision) (flutter/flutter#145371) 2024-03-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0ee413ee276a to 3d909f14118e (5 revisions) (flutter/flutter#145370) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 89df726bf13a to 0ee413ee276a (3 revisions) (flutter/flutter#145365) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3fde3678a357 to 89df726bf13a (1 revision) (flutter/flutter#145359) 2024-03-18 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.24.7 to 3.24.8 (flutter/flutter#145358) 2024-03-18 danny@tuppeny.com Roll pub packages + update DAP tests (flutter/flutter#145349) 2024-03-18 prasadsunny1@gmail.com Fix for issue 140372 (flutter/flutter#144947) 2024-03-18 31859944+LongCatIsLooong@users.noreply.github.com Introduce methods for computing the baseline location of a RenderBox without affecting the current layout (flutter/flutter#144655) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 016206de75bc to 3fde3678a357 (2 revisions) (flutter/flutter#145350) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 90c4d64d410f to 016206de75bc (2 revisions) (flutter/flutter#145345) 2024-03-18 32242716+ricardoamador@users.noreply.github.com Switch hot_mode_dev_cycle_linux__benchmark to run in postsubmit (flutter/flutter#145343) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9162c8309e24 to 90c4d64d410f (1 revision) (flutter/flutter#145342) 2024-03-18 15619084+vashworth@users.noreply.github.com Add --no-dds to Mac_arm64_ios version of hot_mode_dev_cycle_ios__benchmark (flutter/flutter#145335) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 89fb886a162c to 9162c8309e24 (2 revisions) (flutter/flutter#145336) 2024-03-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from 86de0f75606f to 89fb886a162c (1 revision) (flutter/flutter#145327) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Description
The PR updates
SingleActivator
in order to add a parameter for specifying that a shortcut depends on NumLock key state.Somewhat similarly to what is possible with common modifiers expect that a boolean is not enough in this case because: by default, a shortcut should ignore the NumLock state and it should be possible to define shortcuts that require NumLock to be locked and other that require it to be unlocked.
@gspencergoog I considered defining a new
ShortcutActivator
implementation for this, but I thinks that adding the feature directly toSingleActivator
results in a cleaner API.Related Issue
Fixes #145144
Preparation for #144936
Tests
Adds 3 tests.