This class is modelled after PopUpMenu, but implements submenus.
space | open |
arrows | left, right, up, down |
[a-z,0-9] | jump to item |
return | select |
escape | close |
Menues that are close to the right-hand side of the screen and extend across the border will overlap.
Create a new menu. To make it work one must set a -tree.
Dictionary of dictionaries. Branches terminate if they have an empty dictionary as a value (= leaf).
The tree dictionary is unordered. By default branches and leaves on the same level will be sorted and displayed in alphabetic order. See -sortFunc.
Below is an example of a tree without branches - all leaves (keys) are on the same leve. This will be similar to a regular PopUpMenu.
Next an example of a nested structure. This will create a submenu.
Symbols, numbers and strings can be used as keys (compared to the old version which only accepted symbols).
Determines whether the action is triggered when selecting already selected item. Defaults to false.
A Boolean. |
Array of keys pointing to current selection (leaves only). Empty if nothing selected. See -currentPath for reporting both branches and leaves.
Array of keys pointing to current selection. Empty if nothing selected.
Set a custom Function to sort the tree dictionary in other ways than the default alphabetic order. Note that the -tree keys are converted and passed in to this function as symbols.
Get or set the selection color.
Get or set the value.
path |
Should be an array of keys. |
Array of keys pointing to the last selected node/leaf. nil
if nothing selected.
Set the value and evaluate the action.
path |
Should be an array of keys. |
Function that gets evaluated when some leaf is selected. Arguments passed in: this, value
Function that gets evaluated when the popup menu is clicked. Arguments passed in: this, mouseX, mouseY
This can be used to automatically populate -tree and keep it in sync with files in a folder. See examples below.
Function that gets evaluated when the popup menu closes. Arguments passed in: this, mouseX, mouseY
Get or set the position and dimension of the menu as a Rect.
Get or set the Font.
Get or set the selection color.
Get or set the String used as branch indicator. By default this is "▶"
Set the speed of the flashes for the select item animation. The default is 0.1
Set the number of flashes for the select item animation. The default is 1
Get or set the size of the side margins. The default is 4