|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.ui.ContextMenu
A context menu that provides actions "appropriate" to the current field hierarchy.
For example, an EditField in the heirarchy might add actions to the context menu for Cut and Paste operations (if appropriate for that particular edit field).
Each application supports a single context menu. Each time a Field in the
application has its getContextMenu method
invoked (to show the context menu for that field), the application's context
menu gets re-populated (with the menu items appropriate for that field). The
context menu's contents remain set until the next call to
getContextMenu.
The context menu is stored as a simple array of MenuItem
objects. The first menu item in the list, therefore, has position zero.
Each menu item added to the menu has, among other attributes, a priority value. The menu item with the highest priority (the priority value closest to zero) becomes the default menu item for the context menu. When the context menu appears to the user, the default menu item is selected, so the user simply has to click to choose it.
| Method Summary | ||
void |
addItem(MenuItem item)
Adds an item to the menu. |
|
MenuItem |
getDefaultItem()
Gets the default item. |
|
static ContextMenu |
getInstance()
Retrieves instance of the system context menu. |
|
int |
getSize()
Gets the number of items in the menu. |
|
Field |
getTarget()
Gets the target field for the context menu. |
|
boolean |
isEmpty()
Determines if the context menu is empty. |
|
void |
setTarget(Field target)
Sets the target field for the context menu. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public void addItem(MenuItem item)
Use this method to add a MenuItem to the application's
context menu. If the priority of the new item to add is "higher" (closer
to zero) than that of the current default item, this method makes the
newly added item the default.
If you override Field.makeContextMenu(ContextMenu), then you
should invoke this method there.
item - Menu item to add to context menu.IllegalstateException - if setTarget has not yet been calledpublic MenuItem getDefaultItem()
public int getSize()
It's prudent to use this menu to retrieve the number
of menu items in the context menu's list before
using getItems to retrieve the list itself.
public Field getTarget()
When a field's getContextMenu method is
invoked, it calls setTarget to point to itself as
the target field.
public boolean isEmpty()
public void setTarget(Field target)
When a field's getContextMenu method is
invoked, it calls this method passing itself in as the
parameter, making itself the target field for the context
menu.
This method sets the current default priority value to the maximum integer value (absolutely lowest priority), and the number of items to zero.
Subsequent calls to addItem are used to
populate the context menu.
target - Field to set as target for context menu.
|
|||||||||
| 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.