mirror of https://github.com/buggins/dlangui.git
AppFrame: main menu accelerators
This commit is contained in:
parent
f11435e4b6
commit
f509171b04
|
@ -45,6 +45,16 @@ class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
|||
init();
|
||||
}
|
||||
|
||||
/// map key to action
|
||||
override Action findKeyAction(uint keyCode, uint flags) {
|
||||
if (_mainMenu) {
|
||||
Action action = _mainMenu.findKeyAction(keyCode, flags);
|
||||
if (action)
|
||||
return action;
|
||||
}
|
||||
return super.findKeyAction(keyCode, flags);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
_mainMenu = createMainMenu();
|
||||
_toolbarHost = createToolbars();
|
||||
|
|
|
@ -84,6 +84,20 @@ class MenuItem {
|
|||
return _subitems[index];
|
||||
}
|
||||
|
||||
/// map key to action
|
||||
Action findKeyAction(uint keyCode, uint flags) {
|
||||
if (_action) {
|
||||
if (_action.checkAccelerator(keyCode, flags))
|
||||
return _action;
|
||||
}
|
||||
for (int i = 0; i < subitemCount; i++) {
|
||||
Action a = subitem(i).findKeyAction(keyCode, flags);
|
||||
if (a)
|
||||
return a;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@property MenuItemType type() const {
|
||||
if (id == SEPARATOR_ACTION_ID)
|
||||
return MenuItemType.Separator;
|
||||
|
@ -676,6 +690,13 @@ class MenuWidgetBase : ListWidget {
|
|||
if (thisPopup !is null)
|
||||
thisPopup.close();
|
||||
}
|
||||
|
||||
/// map key to action
|
||||
override Action findKeyAction(uint keyCode, uint flags) {
|
||||
Action action = _item.findKeyAction(keyCode, flags);
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// main menu (horizontal)
|
||||
|
|
|
@ -924,7 +924,7 @@ class Widget {
|
|||
}
|
||||
|
||||
/// map key to action
|
||||
protected Action findKeyAction(uint keyCode, uint flags) {
|
||||
Action findKeyAction(uint keyCode, uint flags) {
|
||||
Action action = _acceleratorMap.findByKey(keyCode, flags);
|
||||
return action;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue