mirror of https://github.com/buggins/dlangui.git
fix action handling
This commit is contained in:
parent
6f44eb5845
commit
89bd705477
|
@ -24,7 +24,7 @@ import dlangui.widgets.layouts;
|
||||||
import dlangui.widgets.statusline;
|
import dlangui.widgets.statusline;
|
||||||
import dlangui.widgets.toolbars;
|
import dlangui.widgets.toolbars;
|
||||||
|
|
||||||
class AppFrame : VerticalLayout, MenuItemClickHandler {
|
class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
||||||
protected MainMenu _mainMenu;
|
protected MainMenu _mainMenu;
|
||||||
protected StatusLine _statusLine;
|
protected StatusLine _statusLine;
|
||||||
protected ToolBarHost _toolbarHost;
|
protected ToolBarHost _toolbarHost;
|
||||||
|
@ -64,7 +64,14 @@ class AppFrame : VerticalLayout, MenuItemClickHandler {
|
||||||
|
|
||||||
/// override to handle main menu commands
|
/// override to handle main menu commands
|
||||||
override bool onMenuItemClick(MenuItem item) {
|
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
|
/// create main menu
|
||||||
|
|
|
@ -52,6 +52,11 @@ class ToolBarHost : HorizontalLayout {
|
||||||
}
|
}
|
||||||
return null;
|
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
|
/// image button for toolbar
|
||||||
|
|
|
@ -906,7 +906,6 @@ class Widget {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// called to process click and notify listeners
|
// called to process click and notify listeners
|
||||||
protected bool handleClick() {
|
protected bool handleClick() {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
Loading…
Reference in New Issue