I would like to write less code for simple menus that just set/change a configuration item. I now need to write delegates to do simple things and need to pass around objects to make sure a delegate has access to it. I would like to write something more concise like this:
var menu = new Ui.Menu2({
:title => "Some title",
});
menu.addItem(
new Ui.menuItem(
"Some label",
"",
:id,
{ callback => object.invoke(:method, [ args ]) }
),
);
var itemId = menu.findItemById(id);
var item = menu.getItem(itemId);
item.setCallback(object.invoke(:method, [ args ]);
menu.updateItem(item, itemId);
// or maybe, and I prefer this over the former
menu.addItem(
new Ui.menuItem(
"Some label",
"",
:id,
null,
),
object.invoke(:method, [ args ]),
);
var itemId = menu.findItemById(id);
menu.setCallbackOnItem(itemId, object.invoke(:method), [ args ]);
-
jim_m_58
-
Cancel
-
Vote Up
0
Vote Down
-
-
More
-
Cancel
Comment-
jim_m_58
-
Cancel
-
Vote Up
0
Vote Down
-
-
More
-
Cancel
Children