Skip to content
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

Add initial shortcut support to menubar for macOS #422

Merged
merged 1 commit into from
Jun 6, 2019

Conversation

stuartmorgan
Copy link
Collaborator

Adds the ability to set shortcuts for menu items, using the same format
on the Dart side that will be used for Action shorcuts. Currently only
the macOS platform implementation uses them.

There are some limitations around non-ascii keys, which will be resolved
via a full generated keymap once this is folded into Flutter, but common
cases are special-cased, and more special-casing can be added as needed
by clients.

Adds various shortcuts to the testbed app, exercising various modifiers
and special cases.

Partially addresses #95

Adds the ability to set shortcuts for menu items, using the same format
on the Dart side that will be used for Action shorcuts. Currently only
the macOS platform implementation uses them.

There are some limitations around non-ascii keys, which will be resolved
via a full generated keymap once this is folded into Flutter, but common
cases are special-cased, and more special-casing can be added as needed
by clients.

Adds various shortcuts to the testbed app, exercising various modifiers
and special cases.

Partially addresses google#95
@stuartmorgan stuartmorgan requested a review from krisgiesing June 5, 2019 23:08
Copy link
Contributor

@krisgiesing krisgiesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, questions are food for thought but not blocking.

plugins/menubar/lib/src/menu_channel.dart Show resolved Hide resolved
}

// Returns the NSEventModifierFlags of |modifiers|, a value from kShortcutKeyModifiers.
static NSEventModifierFlags KeyEquivalentModifierMaskForModifiers(NSNumber *modifiers) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle the other modifiers here? (NSEventModifierFlagCapsLock, NSEventModifierFlagNumericPad, NSEventModifierFlagHelp, NSEventModifierFlagFunction)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only needs to handle the values that the platform channel can send, which is these four. If you mean do we need to add those on the Dart side too, same comment about actual use case applies to those too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My brief perusal of the docs suggested that numpad keys would be handled by a combination of number string and the NSEventModifierFlagNumericPad modifier, as opposed to the numpad keys having separate entries they way they are in LogicalKeyboardKey on the Dart side. It looks like this code can't distinguish between numpad number keys and regular numeric keys. Then there are similar questions about the other things that macOS considers modifiers which aren't in the set of allowed modifiers that this plugin defines.

But anyway, yeah, it's not clear how much people need that.

@stuartmorgan stuartmorgan merged commit e05ec61 into google:master Jun 6, 2019
@stuartmorgan stuartmorgan deleted the menu-shortcuts-macos branch June 6, 2019 00:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants