HandlePopupMenu

From Planimate Knowledge Base
Revision as of 11:55, 14 July 2014 by Craig.Chandler (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
$R = HandlePopupMenu($1)

$R = Result
$1 = Table

Routine Operation that interprets columns in table as depth/name/index/unselectable/selected(tick) and builds and displays a popup menu. Selection of an item in the menu or dismissing the menu returns a result ($R).

The operation takes a 5 column table as a parameter (the table can have more than 5 columns but only the first 5 are used). The name of the columns are not important but the positions must be ordered as follows.

The columns are:

depth
sets the depth of the submenu, 0 = top level
label
the text label for the menu item
id
return id for menu item
unavailable
sets the menu item to unselectable (gray), <>0 = unselectable
tick
places a menu tick next to the menu item


The menu structure is defined by enumerating the menu items in prefix order, for example for:

File Edit Tools
New Cut Add ---> Table
Load Paste Label
Save Reset
Quit


depth label id unavailable tick
0 File 0 0 0
1 New 1 0 0
1 Load 2 0 0
1 Save 3 1 0
1 Quit 4 0 0
0 Edit 0 0 0
1 Cut 5 0 0
1 Paste 6 0 0
0 Tools 0 0 0
1 Add 0 0 0
2 Table 7 0 0
2 Label 8 0 0
1 Reset 9 0 0

You can use a label of '-' as a separator between menu items.

When a menu selection is made the return attribute ($R) will contain the index (from the index column) of the selected menu item.

Menu items flagged as unavailable will be shown in Grey and cannot be selected.

Useful when creating end user applications with Planimate.