|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.ui.component.Menu
Provides a Menu.
Behaviour
Displays a menu in the top right corner of the screen. A menu is a vertically
arranged list of items. The currently selected menu item is marked by
inverting its rectangle.
To choose the selected menu item, one can either click the trackwheel or press ENTER. To dismiss the menu without choosing an item, one can press ESCAPE.
Menus also support prefix searching; if one presses a letter key, the next menu item that starts with that character gets selected.
A SeparatorField object can be added to a menu in the following
ways:
add(ContextMenu, boolean) method and set the
addSeparator argument to true.
addSeparator() method to add a separator.
| Field Summary | ||
static int |
CANCELLED
Value returned from show() when the menu is cancelled. |
|
static int |
INSTANCE_CONTEXT
Menu instance is the context one. |
|
static int |
INSTANCE_CONTEXT_SELECTION
Menu instance is during selection. |
|
static int |
INSTANCE_DEFAULT
Menu instance is the default one. |
|
static long |
SORTED
Style that sorts the menu. |
|
static int |
UNDEFINED
Value of an undefined item ID. |
|
| Constructor Summary | ||
Menu()
Constructs a new Menu instance. |
||
Menu(long style)
Constructs a new Menu instance with the given style. |
||
| Method Summary | ||
void |
add(ContextMenu contextMenu)
Adds a list of menu items to this menu. |
|
void |
add(ContextMenu contextMenu,
boolean addSeparator)
Adds a list of menu items to this menu. |
|
void |
add(MenuItem item)
Adds a menu item to this menu. |
|
void |
add(String text,
Object cookie,
int id)
Deprecated. Use add(MenuItem.separator(int)). |
|
int |
addSeparator()
Adds separator item to this menu. |
|
void |
close()
Closes the menu. |
|
void |
deleteAll()
Removes all items from this menu. |
|
void |
deleteItem(int position)
Deletes an item from this menu. |
|
MenuItem |
getDefault()
Retrieves this menu's default item. |
|
MenuItem |
getItem(int position)
Retrieves menu item by position. |
|
Object |
getItemCookie(int position)
Deprecated. Use getItem(int) that returns a MenuItem. |
|
int |
getItemId(int position)
Deprecated. Use getItem(int) that returns a MenuItem. |
|
Object |
getSelectedCookie()
Deprecated. Use getSelectedItem() that returns a MenuItem. |
|
int |
getSelectedId()
Deprecated. Use getSelectedItem() that returns a MenuItem. |
|
MenuItem |
getSelectedItem()
Retrieves currently selected item. |
|
int |
getSize()
Retrieves the number of items in this menu. |
|
boolean |
isDisplayed()
Determines if this menu is currently visible. |
|
void |
setDefault(int position)
Sets this menu's default item. |
|
void |
setDefault(MenuItem item)
Sets this menu's default item. |
|
void |
setItemHighlight(int position,
boolean highlight)
Controls highlighting of a menu item. |
|
void |
setTarget(Field field)
Deprecated. |
|
int |
show()
Shows the menu to the user. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int CANCELLED
Has the value -1.
public static final int INSTANCE_CONTEXT
public static final int INSTANCE_CONTEXT_SELECTION
public static final int INSTANCE_DEFAULT
| Constructor Detail |
| Method Detail |
public void add(ContextMenu contextMenu)
This method invokes add(MenuItem) for each item in your
provided array.
This method does not add a separator.
contextMenu - Array of menu items to add to this menu.NullPointerException - Thrown if contextMenu parameter is null.public void add(ContextMenu contextMenu, boolean addSeparator)
This method simply invokes add(MenuItem) for each item in
your provided array.
contextMenu - Array of menu items to add to this menu.addSeparator - A boolean indicating whether or not to add a
separator if the context menu is non empty.NullPointerException - Thrown if contextMenu parameter is null.public void add(MenuItem item)
When the user selects this menu item, the system invokes its
Runnable.run() method.
item - Menu item to add; if null, this method does nothing.public void add(String text, Object cookie, int id)
add(MenuItem.separator(int)).
text - Text to display for the new item.cookie - Cookie to associate with the new item.id - ID to associate with the new item.NullPointerException - If text parameter is null.public int addSeparator()
The separator is added after the last item in the menu.
public void deleteAll()
Notice that this method does not delete the special Hide Menu item, nor the separator immediately following Hide Menu. This method also removes the focus from the menu, to assure that a new default item is chosen when the menu appears.
public void deleteItem(int position)
position - Position of menu item to delete.IllegalArgumentException - If position is invalid.public MenuItem getDefault()
public MenuItem getItem(int position)
position - Position of menu item to retrieve.public Object getItemCookie(int position)
position - Position of the menu item.IllegalArgumentException - If position is invalid.public int getItemId(int position)
position - Position of the menu item.UNDEFINED.IllegalArgumentException - If position is invalid.public Object getSelectedCookie()
This method only returns a meaningful method after this method is
shown with show().
public MenuItem getSelectedItem()
public int getSize()
Note that this method does not include the special Hide Menu item in its count, but does include separator items.
public boolean isDisplayed()
public void setDefault(int position)
When this menu is activated, the default menu item is pre-selected.
This call may be unsuccessful in case default the menu item was set by
ContextMenu.
position - Position of the default menu item.IllegalArgumentException - If position is invalid.public void setDefault(MenuItem item)
When this menu is activated, the default menu item is pre-selected.
This call may be unsuccessful in case default menu item was set by
ContextMenu or in case when menu item parameter was not added to
current menu prior to setDefault was called.
item - Item to make as the first selection.
public void setItemHighlight(int position,
boolean highlight)
position - Position of the menu item.highlight - If true, this method highlights a menu item and draws a
box around it; if false, turn off the highlighting for menu item.public void setTarget(Field field)
This is the same field that creates the context menu.
field - Target field for this menu.public int show()
This menu shows this menu to the user; if a default menu item has been set for this menu, it shows pre-selected; otherwise, the first menu item in the list is selected.
This method blocks until the user either chooses a menu item, or dismisses the menu by pressing ESCAPE.
If the user chooses a menu item, this menu returns that item's position in the menu.
It also invokes contextMenu.setTarget(null) to ensure that the context menu it updated properly next time it is used.
CANCELLED.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.