Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


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

Constructors

UIContextMenu

public UIContextMenu(UIMenuList uiMenuList);

Creates a context menu control with the specified menu. The control itself has no content.

ParameterDescription
uiMenuList The UIMenuList object containing the content of the associated pop-up menu.

UIContextMenu

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.

ParameterDescription
comp The component to be displayed within the control.
uiMenuList The UIMenuList object containing the content of the associated pop-up menu.

Methods

action

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.

ParameterDescription
e The event posted to the control.
o The object that posted the event.

ended

public void ended(Event event);

Called by the control's associated pop-up menu once the menu is closed.

Return Value:

No return value.

ParameterDescription
event The event that will be fired after end is complete; null if no event will be fired.

Overrides:

ended(Event) in UIMenuLauncher.

getPlacement

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.

ParameterDescription
Dim The preferred size of the pop-up menu.

Overrides:

getPlacement(Dimension) in UIMenuLauncher.

getRoot

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.

getUserItem

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.

ParameterDescription
x The x coordinate of the menu item's upper-left corner.
y The y coordinate of the menu item's upper-left corner.

getUserItem

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.

ParameterDescription
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.

launchAt

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.

ParameterDescription
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.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.