Skip to content

Components

PopupMenu

A list of commands that opens where you click, such as a right-click menu: Load, Rename, a divider, Delete. It opens with its corner at that point rather than centred like a Dropdown, and clicking anywhere closes it. Goes under a Canvas.

On this page

Add it

+ Add node → Popup Menu creates a node with it already on. Already have a node for it? Add component → PopupMenuComponent.

From a script

A script on the same node writes these fields by name. PopupMenuComponent is the name to pass.

rgs
set_text("PopupMenuComponent", "opens", "");
set_number("PopupMenuComponent", "width", 160.0);
set_number("PopupMenuComponent", "item_height", 28.0);
set_number("PopupMenuComponent", "separator_height", 9.0);
set_number("PopupMenuComponent", "shortcut_width", 56.0);
set_number("PopupMenuComponent", "scale", 1.0);
set_number("PopupMenuComponent", "border", 0.0);
set_point("PopupMenuComponent", "padding", vec2(0.0, 0.0));
set_colour("PopupMenuComponent", "background", vec4(0.1, 0.1, 0.13, 1.0));
set_colour("PopupMenuComponent", "highlight", vec4(0.25, 0.25, 0.32, 1.0));
set_colour("PopupMenuComponent", "foreground", vec4(0.9, 0.9, 0.94, 1.0));
set_colour("PopupMenuComponent", "disabled", vec4(0.45, 0.45, 0.5, 1.0));
set_colour("PopupMenuComponent", "rule", vec4(0.3, 0.3, 0.36, 1.0));

Fields

FieldScript nameKindDefaultWhat it does
Itemsitemslist1 entriesThe rows, in order.
FieldScript nameKindDefaultWhat it does
LabellabeltextnoneWhat it reads. Ignored on a separator.
ActionactiontextnoneReported when this item is chosen.
EnabledenabledcheckboxnoneWhether it can be chosen.
SeparatorseparatorcheckboxnoneWhether this is a divider between groups, rather than a command.
ShortcutshortcuttextnoneThe key that chooses this row while the menu is open, named as the input map names keys, such as KeyU or Ctrl+KeyS.
OpensopenstextemptyAction whose click opens this menu.
Widthwidthnumber, at least 1160 pxHow wide the menu opens, in UI units.
Item Heightitem_heightnumber, at least 128 pxHeight of a command row, in UI units.
Separator Heightseparator_heightnumber, at least 09 pxHeight of a separator row, in UI units.
Shortcut Widthshortcut_widthnumber, at least 056 pxRoom kept at the right of every row for its shortcut key, in UI units.
Scalescalenumber, at least 01Scales the size of the text for a row's label and its shortcut key.
TexturetextureassetnoneA picture to draw the menu on, or none for a flat fill.
Borderbordernumber, at least 00 pxWidth of the picture's nine-slice border, so its corners keep their size as the menu grows.
Paddingpaddingtwo numbers (x, y)(0, 0)How far the rows sit inside the menu's edge, across and down, and the words inside their row.
Colors
Backgroundbackgroundcolour#1a1a21Background of the whole menu.
Highlighthighlightcolour#404052Highlight behind the row under the pointer or the ring.
Foregroundforegroundcolour#e6e6f0Colour of an item's label.
Disableddisabledcolour#737380Colour of a label that cannot be chosen.
Rulerulecolour#4d4d5cColour of the line a separator draws.