POPUP_MENU
Creates a menu composed of MENU_ITEM, MENU_SEPARATOR or FILE_SELECT_MENU elements that will popup when its "Popup" action is executed.
Attributes brief detailed show all inherited
Name | Description | Default | |||
---|---|---|---|---|---|
Exposed Actions | |||||
Popup | Menu pops up at the current mouse location | ||||
Common attributes | |||||
id | Identifier of the element | empty |
Simple Menu Example
Simple popup menu with two elements that pops up when user clicks on "Click Me" text.
- <!-- this popup menu does nothing, just opens -->
- <POPUP_MENU id="menu">
- <MENU_ITEM name="Item1"/>
- <MENU_ITEM name="Item2"/>
- </POPUP_MENU>
- <!-- text to display -->
- <TEXT value="Click Me!">
- <INVISIBLE_ACTION_BUTTON action_id="menu.Popup" width="100%" height="100%"/>
- </TEXT>

Menu Tree
A popup menu can be composed of submenus when inserting MENU_ITEM recursively. You can also use MENU_SEPARATOR to organize your items.
- <POPUP_MENU id="menu">
- <MENU_ITEM name="Sub Menu1">
- <MENU_ITEM name="Sub Item 1-1"/>
- <MENU_ITEM name="Sub Item 1-2"/>
- </MENU_ITEM>
- <MENU_ITEM name="Sub Menu 2">
- <MENU_ITEM name="Sub Item 2-1"/>
- <MENU_ITEM name="Sub Item 2-2"/>
- <MENU_ITEM name="Sub Item 2-3"/>
- </MENU_ITEM>
- <MENU_SEPARATOR />
- <MENU_ITEM name="Item 3"/>
- </POPUP_MENU>
- <TEXT value="Click Me!" h_align="left" v_align="top">
- <INVISIBLE_ACTION_BUTTON action_id="menu.Popup" width="100%" height="100%"/>
- </TEXT>

See example of changing a param value (checked/unchecked) in MENU_ITEM.
Complex menu with actions and file selection
- <!-- our test param -->
- <PARAM id="my_color" type="enumeration" enum_values="red;green;blue" />
- <!-- way to make a popup menu with actions and checked_param_id -->
- <POPUP_MENU id="my_menu">
- <MENU_ITEM action_id="act_red" checked_param_id="color_is_red" />
- <MENU_ITEM action_id="act_green" checked_param_id="color_is_green" />
- <MENU_ITEM action_id="act_blue" checked_param_id="color_is_blue" />
- <MENU_SEPARATOR />
- <MENU_ITEM name="Submenu">
- <MENU_ITEM action_id="act_red" checked_param_id="color_is_red" />
- <MENU_ITEM action_id="act_green" checked_param_id="color_is_green" />
- <MENU_ITEM action_id="act_blue" checked_param_id="color_is_blue" />
- </MENU_ITEM>
- <MENU_SEPARATOR />
- <FILE_SELECT_MENU id="my_fs_menu" directories="$PLUGIN_USER_DOCUMENTS_PATH$" file_types="*.*" name="File select menu" file_path_string_id="string_out" _file_name_string_id="string_out" root_path="$PLUGIN_USER_DOCUMENTS_PATH$"/>
- </POPUP_MENU>
- <!-- actions and formula_param for the popup menu -->
- <ACTION id="act_red" type="Script" script="my_color = 0;" name="Set red" />
- <ACTION id="act_green" type="Script" script="my_color = 1;" name="Set green" />
- <ACTION id="act_blue" type="Script" script="my_color = 2;" name="Set blue" />
- <!-- these formula_params are used for MENU_ITEMs "checked" status -->
- <FORMULA_PARAM id="color_is_red" formula="my_color = 0" />
- <FORMULA_PARAM id="color_is_green" formula="my_color = 1" />
- <FORMULA_PARAM id="color_is_blue" formula="my_color = 2" />
- <TEXT value=" (POPUP_MENU) Click me! " background_color="#fad9c1" height="30">
- <INVISIBLE_ACTION_BUTTON action_id="my_menu.Popup" cursor="system::hand" width="100%" height="100%" />
- </TEXT>
- <!-- row of colored squares -->
- <ROW spacing="5">
- <WIDGET id="w_red" background_color="#ee4035" width="20" height="20" />
- <WIDGET id="w_green" background_color="#7bc043" width="20" height="20" />
- <WIDGET id="w_blue" background_color="#0392cf" width="20" height="20" />
- <PARAM_LINK from="my_color" to="w_red.opacity" formula="0.1+(x==0)" />
- <PARAM_LINK from="my_color" to="w_green.opacity" formula="0.1+(x==1)" />
- <PARAM_LINK from="my_color" to="w_blue.opacity" formula="0.1+(x==2)" />
- <!-- text value -->
- <PARAM_TEXT param_id="my_color" content="Color: {text_value} ({value})" value_format="0.0" />
- </ROW>
- <!-- action is run when param has changed -->
- <ACTION_TRIGGER event_id="my_color.value_changed" script="
- int val = my_color;
- string_out = "Color changed to "+my_color.text_value+" ("+val+")";
- text_string_out.opacity = 1;
- animate_opacity = 0;
- " requires="my_color.*;string_out;animate_opacity;text_string_out.opacity" />
- <!-- string to show event information -->
- <STRING id="string_out" />
- <TEXT id="text_string_out" string_id="string_out" width="400" />
- <!-- param_animator to fade_out text -->
- <PARAM_ANIMATOR duration_ms="1000" id="animate_opacity" param_id="text_string_out.opacity" exposed="true" />
Simple selection menu (other way)
You may also be aware of an INVISIBLE_PARAM_MENU_BUTTON, which can create simple menus for selecting a PARAM value.
- <!-- our test param -->
- <PARAM id="my_color" type="enumeration" enum_values="red;green;blue" />
- <TEXT value=" (INVISIBLE_PARAM_MENU_BUTTON)" background_color="#fad9c1" height="30">
- <INVISIBLE_PARAM_MENU_BUTTON param_id="my_color" cursor="system::hand" width="100%" height="100%" />
- </TEXT>
- <!-- row of colored squares -->
- <ROW spacing="5">
- <WIDGET id="w_red" background_color="#ee4035" width="20" height="20" />
- <WIDGET id="w_green" background_color="#7bc043" width="20" height="20" />
- <WIDGET id="w_blue" background_color="#0392cf" width="20" height="20" />
- <PARAM_LINK from="my_color" to="w_red.opacity" formula="0.1+(x==0)" />
- <PARAM_LINK from="my_color" to="w_green.opacity" formula="0.1+(x==1)" />
- <PARAM_LINK from="my_color" to="w_blue.opacity" formula="0.1+(x==2)" />
- <!-- text value -->
- <PARAM_TEXT param_id="my_color" content="Color: {text_value} ({value})" value_format="0.0" />
- </ROW>