andlabs / andlabs/libui

Master issue: new menu API, with actions and keyboard shortcuts

オープン
#321 コメント 16 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
C
スター
10.9k
フォーク
612
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。