Class UIContextMenu
public class UIContextMenu extends UIMenuLauncher
{
// Constructors
public UIContextMenu(UIMenuList uiMenuList);
public UIContextMenu(IUIComponent comp, UIMenuList uiMenuList);
// Methods
public boolean action(Event e, Object o);
public void ended(Event event);
public Rectangle getPlacement(Dimension Dim);
public IUIRootContainer getRoot();
public UIMenuItem getUserItem(int x, int y);
public UIMenuItem getUserItem(int x, int y, IUIComponent parent);
public boolean launchAt(int x, int y, IUIComponent parent);
}
This class implements a context menu or shortcut menu that manages a vector of buttons, one of which is a default. A context menu is typically launched when an object is clicked with the right mouse button. The menu can be posted anywhere on the screen.
The context menu extends a UIMenuLauncher with the ability to be launched at a particular location on the screen.
UIComponent
|
+--UIContainer
|
+--UIStateContainer
|
+--UISingleContainer
|
+--UIMenuLauncher
|
+--UIContextMenu
public UIContextMenu(UIMenuList uiMenuList);
Creates a context menu control with the specified menu. The control itself has no content.
Parameter | Description |
uiMenuList
| The UIMenuList object containing the content of the associated pop-up menu.
|
public UIContextMenu(IUIComponent comp, UIMenuList uiMenuList);
Creates a context menu control using the specified component for content and the specified menu.
Note To receive event notification, extend UIContextMenu and catch the events there.
Parameter | Description |
comp
| The component to be displayed within the control.
|
uiMenuList
| The UIMenuList object containing the content of the associated pop-up menu.
|
public boolean action(Event e, Object o);
Responds to an action that has occurred within the control (or any of its descendants).
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the control.
|
o
| The object that posted the event.
|
public void ended(Event event);
Called by the control's associated pop-up menu once the menu is closed.
Return Value:
No return value.
Parameter | Description |
event
| The event that will be fired after end is complete; null if no event will be fired.
|
Overrides:
ended(Event) in UIMenuLauncher.
public Rectangle getPlacement(Dimension Dim);
Called by the control's pop-up menu when the menu is to be displayed.
Return Value:
Returns the bounding rectangle (in screen coordinates) of the pop-up menu.
Parameter | Description |
Dim
| The preferred size of the pop-up menu.
|
Overrides:
getPlacement(Dimension) in UIMenuLauncher.
public IUIRootContainer getRoot();
Retrieves the first component in the control's chain that implements the IUIRootContainer interface.
Return Value:
Returns the root container if successful; otherwise, returns null.
public UIMenuItem getUserItem(int x, int y);
Retrieves the item selected in the control's associated pop-up menu.
Note This is a blocking call.
Return Value:
Returns the menu item that was selected; returns null if none was selected.
Parameter | Description |
x
| The x coordinate of the menu item's upper-left corner.
|
y
| The y coordinate of the menu item's upper-left corner.
|
public UIMenuItem getUserItem(int x, int y, IUIComponent parent);
Retrieves the item selected in the control's associated pop-up menu.
Note This is a blocking call.
Return Value:
Returns the menu item that was selected; returns null if none was selected.
Parameter | Description |
x
| The x coordinate of the menu item's upper-left corner.
|
y
| The y coordinate of the menu item's upper-left corner.
|
parent
| The parent of the item.
|
public boolean launchAt(int x, int y, IUIComponent parent);
Launches the control's associated pop-up menu at the specified location.
Return Value:
Returns true if the pop-up menu was launched; otherwise, returns false.
Parameter | Description |
x
| The x coordinate for the menu's upper-left corner.
|
y
| The y coordinate for the menu's upper-left corner.
|
parent
| The parent.
|