pp108 : Contextmenu

Contextmenu

The Contextmenu control adds a shortcut menu to the XForm. You can attach the Contextmenu control to one or more controls in the XForm, and customize it by adding relevant menu items that need to be displayed at run time. You can also add separators to group menu items in the context menu. When attached to a control, the shortcut menu appears when you right-click the control.

A Contextmenu control and the menu items added to it can be further customized by modifying their property sheets. This control is derived from the AJAX Toolkit library - Contextmenu. For details about the control's behavior and functionality, see Contextmenu.

Properties, Events, and Methods of the Control

The properties, events, and methods associated with the Contextmenu control define its behavior. You can set them either through the control's property sheet or programmatically using the APIs. For details, see Contextmenu.

The following XForms-related properties, events, and methods are available for the control:

Table 1. List of Properties

Design-time property

Runtime property

Description

ID

Sets the string that identifies the control on an XForm. If not specified, a unique ID is automatically generated.

Load Automatically

automaticLoad

Denotes whether the context menu will be automatically loaded when the page is loaded.

Stickable

Denotes whether a menu can be made sticky. A sticky menu can be dragged to reposition it on a page, and is not hidden when it loses focus.

Sticky

Denotes whether a menu will remain visible even when it loses focus. It is not selected, by default.

Apperance

Sets the position in which the context menu is displayed. The available options are:

  • dropdown: The context menu is displayed as a drop-down list with respect to the parent.
  • standard: Default. The context menu is displayed at the coordinates where you right-clicked.

Task Part

Creates a task part for the control. Selecting the check box, displays the Task Part pane.

Table 2. List of Events

Event

Description

On Context

Fires when the element to which the context menu is attached is right-clicked.

Table 3. List of Methods

Method

Description

addListener(sEventName, fpFunction)

This method registers a function to an event, such that the function gets called when the event is fired on the control.

disable()

This method disables the menu item in the context menu.

enable()

This method enables the menu item in the context menu.

hide()

This method hides a context menu or a menu item when the event is fired.

isEnabled()

This method retrieves the value that denotes whether the control is enabled or not.

removeListener(sEventName, fpFunction)

This method unregisters a function from an event, such that the function stops getting called when the event is fired on the control.

show()

This method shows a context menu or a menu item when the event is fired.