|
|||||||||
| 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
Screen to provide 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.
| Inner Class Summary |
| Field Summary | ||
static int |
CANCELLED
Value returned from show() when the menu is cancelled. |
|
static long |
SORTED
Style that sorts the menu. |
|
static int |
UNDEFINED
Value of an undefined item ID. |
|
| Constructor Summary | ||
Menu()
Constructs a new Menu. |
||
Menu(long style)
Constructs a new Menu 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)
Adds text item to this menu with the given cookie and ID. |
|
int |
addSeparator()
Adds separator item to this menu. |
|
void |
deleteAll()
Removes all items from this menu. |
|
void |
deleteItem(int position)
Deletes an item from this menu. |
|
Object |
getItemCookie(int position)
Retrieves the cookie for menu item at provided position. |
|
int |
getItemId(int position)
Retrieves the ID for menu item at provided position. |
|
Object |
getSelectedCookie()
Retreives cookie for the selected menu item. |
|
int |
getSelectedId()
Retrieves the ID of the selected menu 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. |
|
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.
| Constructor Detail |
public Menu(long style)
style - Combination of style flags from Screen or
Manager.| Method Detail |
public void add(ContextMenu contextMenu)
This method simply invokes add(MenuItem) for each item in
your provided array.
Does not add a separator.
items - Array of menu items to add to this menu.NullPointerException - if contextMenu is nullpublic void add(ContextMenu contextMenu, boolean addSeparator)
This method simply invokes add(MenuItem) for each item in
your provided array.
items - Array of menu items to add to this menu.addSeparator - add a separator if the context menu is non empty NullPointerException - if contextMenu is nullpublic void add(MenuItem item)
item is null, this call is a nop.
When the user selects this menu item, the system invokes its
Runnable.run() method.
item - Menu item to add.public void add(String text, Object cookie, int id)
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 is nullpublic int addSeparator()
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 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 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 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 setDefault(int position)
When this menu is activated, the default menu item is pre-selected.
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.
item - Item to make as the first selection.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-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.