AppFrame: main menu accelerators

This commit is contained in:
Vadim Lopatin 2015-01-26 16:28:42 +03:00
parent f11435e4b6
commit f509171b04
3 changed files with 32 additions and 1 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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;
}