Master issue: new menu API, with actions and keyboard shortcuts
- Vorherrschende Sprache
- C
- Sterne
- 10.9k
- Forks
- 612
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The existing menu system is weird and will be hard to expand. OS X defines an entire interface of standard "actions" (NSResponder) with standard menu items and standard keyboard shortcuts, which will affect things as well. We'll need something different.
Originally I wasn't sure about what to do, but now I decided to go with an action-based system. You make an action object that has an event handler. The event handler would either contain the current control, the current window, or some combination of the two (or neither). There will be a set of standard actions, some of which can't be directly overridden; uiArea will provide an interface to handle these. Custom actions might be doable in the future; IDK.
Menus are now per-window. Most standard menu items are created by passing the standard actions into the menu functions. Standard menubar menus will also need to be made somehow. The OS X app menu will affect things here. You'll need to have an action in a menu to have the associated keyboard shortcut enabled (this is a limitation of OS X; TODO I could possibly work around it but IDK how — and then I would need to decide where the accelerator goes, in the action or the menu item). I also need to see if OS X automatically handles per-window menus or if I need to do it myself.
There should also be some way to determine whether an action is applicable in the present situation or not. This is how menu items are enabled or disabled. Again, OS X has the interfaces defined to do this (NSUserInterfaceValidation).
Other controls could also use actions for events somehow.
How to implement this on the other platforms isn't as certain, but the existing bugs on this issue have lots of notes; will need to refer to them.
Keyboard mnemonics should also be possible in menus, but on systems that support them.
Of course, I need to document what is platform-specific so app developers don't make features that are only accessible on some platforms because they are only accessible via one method that isn't available on all platforms.
This would also extend to right-click menus.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.