fix action handling

This commit is contained in:
Vadim Lopatin 2015-01-16 16:40:03 +03:00
parent 6f44eb5845
commit 89bd705477
3 changed files with 14 additions and 3 deletions

View File

@ -24,7 +24,7 @@ import dlangui.widgets.layouts;
import dlangui.widgets.statusline;
import dlangui.widgets.toolbars;
class AppFrame : VerticalLayout, MenuItemClickHandler {
class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
protected MainMenu _mainMenu;
protected StatusLine _statusLine;
protected ToolBarHost _toolbarHost;
@ -64,7 +64,14 @@ class AppFrame : VerticalLayout, MenuItemClickHandler {
/// override to handle main menu commands
override bool onMenuItemClick(MenuItem item) {
return false;
// default handling: call Action handler
return onMenuItemAction(item.action);
}
/// override to handle main menu actions
bool onMenuItemAction(const Action action) {
// default handling: dispatch action using window (first offered to focused control, then to main widget)
return window.dispatchAction(action);
}
/// create main menu

View File

@ -52,6 +52,11 @@ class ToolBarHost : HorizontalLayout {
}
return null;
}
/// override to handle specific actions
override bool handleAction(const Action a) {
// route to focused control first, then to main widget
return window.dispatchAction(a);
}
}
/// image button for toolbar

View File

@ -906,7 +906,6 @@ class Widget {
return false;
}
// called to process click and notify listeners
protected bool handleClick() {
bool res = false;