|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Object
Menu
public class Menu
This class represents the Menus that are shown to user. Menu supports nesting and hiding/showing of individual menu items.
Methods are designed so that it's easy to create menu structures with method chaining:
Menu m = Menu()
.add(CMD_OPEN, "Open")
.add(CMD_REMOVE, "Remove")
.add(CMD_ADD, "Add")
.begin(CMD_MORE, "More")
.add(CMD_SYNC, "Synchronize")
.add(CMD_SETTINGS, "Settings")
.end()
.add(CMD_EXIT, "Exit")
Menu getMenu(Shell shell, Component focused)
{
return m.reset().enable(CMD_OPEN, focused != null)
.enable(CMD_REMOVE, focused != null)
.enable(CMD_SYNC, isOnline());
}
The upper case references are to ids created in the script:
const int CMD_OPEN = 0; const int CMD_REMOVE = 1; // etc...
These ids are given back in callback function arguments
that are called when an action has happened:
Script.actionPerformed(Shell, Component, int) or
ActionCallback.actionPerformed(Shell, Component, int)
MenuItem,
Script.getMenu(Shell, Component),
Script.getSoftKey(Shell, Component, int),
Callbacks| Constructor Summary | |
|---|---|
Menu()
Constructs a new Menu instance. |
|
| Method Summary | |
|---|---|
Menu |
add(int id,
String text)
Creates a new MenuItem with specified action id and text. |
Menu |
begin(int id,
String text)
Creates a new MenuItem with sub menu. |
Menu |
enable(int id,
boolean enabled)
Enable or disable menu item with specified action id. |
Menu |
end()
Closes sub menu and returns to parent menu. |
MenuItem |
get(int id)
Returns MenuItem with specified action id. |
void |
open(Shell parent)
Opens this menu. |
Menu |
reset()
Resets the focus and sets all MenuItems visible. |
| Methods inherited from class Object |
|---|
toString, equals, hashCode |
| Methods inherited from |
|---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Menu()
| Method Detail |
|---|
public Menu add(int id,
String text)
id - An action id. It is passed to Script.actionPerformed(Shell, Component, int)
when user selects this menu item. It can also be used to
enable or disable this item.text - Text to show
public Menu begin(int id,
String text)
id - An action id. It can be used to enable or disable
this item.text - Text to show
end() method to close sub menu and return
parent menupublic Menu end()
public Menu reset()
public Menu enable(int id,
boolean enabled)
id - Action id of MenuItem to hide/showenabled - if true item is shown, otherwise it is
hidden
public MenuItem get(int id)
id - Action id to search for
null if no matching id was found.public void open(Shell parent)
new Shell(null),
it doesn't be visible or in the UI stack.
parent - Parent shell
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||