better actions support

This commit is contained in:
Vadim Lopatin 2015-01-26 16:54:35 +03:00
parent f509171b04
commit 6e1f11fd57
2 changed files with 14 additions and 2 deletions

View File

@ -188,6 +188,14 @@ class MenuItem {
res = add(new MenuItem(subitemAction));
}
return res;
}
/// adds submenu item(s) from one or more actions (will return item for last action)
MenuItem add(const Action[] subitemActions...) {
MenuItem res = null;
foreach(subitemAction; subitemActions) {
res = add(new MenuItem(subitemAction));
}
return res;
}
/// returns text description for first accelerator of action; null if no accelerators
@property dstring acceleratorText() {
@ -228,6 +236,10 @@ class MenuItem {
_action = action;
_enabled = true;
}
this(const Action action) {
_action = action.clone;
_enabled = true;
}
~this() {
// TODO
}

View File

@ -62,7 +62,7 @@ class ToolBarHost : HorizontalLayout {
/// image button for toolbar
class ToolBarImageButton : ImageButton {
this(Action a) {
this(const Action a) {
super(a);
styleId = STYLE_TOOLBAR_BUTTON;
focusable = false;
@ -100,7 +100,7 @@ class ToolBar : HorizontalLayout {
addChild(widget);
}
/// adds image button to toolbar
void addButtons(Action[] actions...) {
void addButtons(const Action[] actions...) {
foreach(a; actions) {
if (a.isSeparator) {
addChild(new ToolBarSeparator());