SetMenuBar: Difference between revisions

From Planimate Knowledge Base
Jump to navigation Jump to search
(New page: Routine Operation that interprets columns in table as depth/name/index and builds a custom menu bar. When a menu bar selection is made the system broadcast "[[_Menu...)
 
(added more info from release notes)
Line 1: Line 1:
[[Routine Operations|Routine Operation]] that interprets columns in table as depth/name/index and builds a custom menu bar.
[[Routine Operations|Routine Operation]] that interprets columns in table as depth/name/index and builds a custom menu bar.


When a menu bar selection is made the system broadcast "[[_Menu Command]]" is sent and the [[Item#Item_Attributes|item attribute]] "_command" will contain the index (from the index column) of the selected menu item.
SetMenuBar enables a complete modeller customsied menubar, with hierarchic menus, to be built in one step. It superceeds the "[[ClearCustomMenubar]]" and "[[AddListToMenu]]" routine operations.
 
The operation takes a 3 column table as a parameter (the table can have more than 3 columns but only the first 3 are used).
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
 
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
|}
 
 
{| border="1"
!depth !! label !! id
|-
|0 || File || 0
|-
|1 || New || 1
|-
|1 || Load || 2
|-
|1 || Save || 3
|-
|1 || Quit || 4
|-
|0 || Edit || 0
|-
|1 || Cut || 5
|-
|1 || Paste || 6
|-
|0 || Tools || 0
|-
|1 || Add || 0
|-
|2 || Table || 7
|-
|2 || Label || 8
|-
|1 || Reset || 9
|}
 
You can use A label of '-' is a separator
 
When a menu bar selection is made the system broadcast "[[_Menu Command]]" is sent and the [[Item Attribute|item attribute]] "_command" will contain the index (from the index column) of the selected menu item.


Useful when creating end user applications with Planimate.
Useful when creating end user applications with Planimate.

Revision as of 14:59, 7 July 2008

Routine Operation that interprets columns in table as depth/name/index and builds a custom menu bar.

SetMenuBar enables a complete modeller customsied menubar, with hierarchic menus, to be built in one step. It superceeds the "ClearCustomMenubar" and "AddListToMenu" routine operations.

The operation takes a 3 column table as a parameter (the table can have more than 3 columns but only the first 3 are used). 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

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
0 File 0
1 New 1
1 Load 2
1 Save 3
1 Quit 4
0 Edit 0
1 Cut 5
1 Paste 6
0 Tools 0
1 Add 0
2 Table 7
2 Label 8
1 Reset 9

You can use A label of '-' is a separator

When a menu bar selection is made the system broadcast "_Menu Command" is sent and the item attribute "_command" will contain the index (from the index column) of the selected menu item.

Useful when creating end user applications with Planimate.