NaturalONE Version 8.3.7
 —  Natural for Ajax  —

XCIPOPUPMENU - Enable Context Menus

With an XCIPOPUPMENU control, you enable the usage of context menus on a page. The application creates the contents of the context menus dynamically at execution time, in response to certain events. There is only one instance of XCIPOPUPMENU needed in each page.

Context menus are supported on the page level and by the following controls:

The following events are raised when the user right-clicks in corresponding areas of the page:

In the event handler of these events, you do no have to necessarily open a context menu; you can also start other operations, if this makes sense. But in order to open a context menu, you need to fill the structure generated for the XCIPOPUPMENU control, which is described below.

If the user selects one of the context menu items, the event xcipopupmenu.reactOnSelect is raised.

This document covers the following topics:


Example

The following screen displays a grid control with several rows. It uses the XCIPOPUPMENU control to show a context menu when the user right-clicks on a row. It shows a different context menu when the user right-clicks in an empty area of the grid and yet another one when the user right-clicks elsewhere in the page.

Example

The XML layout definition contains the following:

<natpage>
    <xcipopupmenu>
    </xcipopupmenu>
...
</natpage>

The example Natural code is contained in the Natural for Ajax demos as program CTRCTX-P.

Top of page

Adapter Interface

1 XCIPOPUPMENU
2 MENUNODE (1:*)
3 ID (A) DYNAMIC
3 IMAGE (A) DYNAMIC
3 LEVEL (I4)
3 REFERENCE (A) DYNAMIC
3 TEXT (A) DYNAMIC
2 ORIGINATORQUERY (A) DYNAMIC
2 SELECTEDREFERENCE (A) DYNAMIC

A menu is reflected by a tree of menu nodes. Each menu node is represented by an ID, a TEXT, an optional IMAGE and a REFERENCE value. When the user selects a menu item, the REFERENCE value of that menu item is then returned in the parameter SELECTEDREFERENCE.

The value of ORIGINATORQUERY is normally not used by Natural applications. The selected line can easier be determined with an NJX:EVENTDATA control.

To include a separator in a context menu, you define "&SEPARATOR" as the TEXT value. Example:

RESIZE ARRAY MENUNODE TO (1:3)
XCIPOPUPMENU.ID(1) := '1'
XCIPOPUPMENU.TEXT(1) := 'Open'
XCIPOPUPMENU.LEVEL(1) := 1
XCIPOPUPMENU.ID(2) := '2'
XCIPOPUPMENU.TEXT(2) := '&SEPARATOR'
XCIPOPUPMENU.LEVEL(2) := 1
XCIPOPUPMENU.ID(3) := '3'
XCIPOPUPMENU.TEXT(3) := 'Close'
XCIPOPUPMENU.LEVEL(3) := 1

If you want to disable menu items, you have to set the value of the withinactivenodes property to "true". In this case, the adapter is generated with an additional INACTIVE field:

1 XCIPOPUPMENU
2 MENUNODE (1:*)
3 ID (A) DYNAMIC
3 IMAGE (A) DYNAMIC
3 INACTIVE (L)
3 LEVEL (I4)
3 REFERENCE (A) DYNAMIC
3 TEXT (A) DYNAMIC
2 ORIGINATORQUERY (A) DYNAMIC
2 SELECTEDREFERENCE (A) DYNAMIC 

By default, the value of the INACTIVE field is "false". If you set it to "true", the corresponding menu item is shown as inactive, that is, it is greyed out and cannot be selected.

Top of page

Built-in Events

xcipopupmenu.reactOnSelect

Top of page

Properties

Basic
withinactivenodes

Set the value of this property to true if you want to disable menu items. In this case, the Natural adapter is generated with an additional INACTIVE field.

Optional

true

false

Top of page