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

Make NSMenuItem#setShortcut work better #6

Open
sindresorhus opened this issue May 19, 2020 · 0 comments
Open

Make NSMenuItem#setShortcut work better #6

sindresorhus opened this issue May 19, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sindresorhus
Copy link
Owner

https://sindresorhus.com/KeyboardShortcuts/Extensions/NSMenuItem.html#/s:So10NSMenuItemC17KeyboardShortcutsE11setShortcut3foryA2CC4NameVSg_tF

Currently, you have to manually disable the keyboard shortcut while the menu item's menu is open. It would be nice if we could somehow handle this automatically.

Is there any way to check if any NSMenu is currently open? We could then disable the global keyboard shortcut listener then. Maybe NSMenu.didBeginTrackingNotification.

setShortcut should maybe also override the .action of the menu item and route the event to the normal KeyboardShortcuts.onKeydown/KeyboardShortcuts.onKeyUp event handlers, so you only need to handle the event in one place.


Alternatively, use the method described in #1, and then use performActionForItem(at: Int) on the relevant menu item.


I'm open to other ideas.

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant