PopupMenu
Inherits: Popup < Control < CanvasItem < Node < Object PopupMenu displays a list of options.
Description
PopupMenu is a Control that displays a list of options. They are popular in toolbars or context menus.
Properties
Methods
Theme Properties
Signals
- id_focused ( int id )
idusingui_uporui_downaction.
- id_pressed ( int id )
idis pressed or its accelerator is activated.
- index_pressed ( int index )
indexis pressed or its accelerator is activated.Property Descriptions
- bool allow_search
true, allows navigatingPopupMenuwith letter keys.
- bool hide_on_checkable_item_selection
true, hides thePopupMenuwhen a checkbox or radio button is selected.
- bool hide_on_item_selection
true, hides thePopupMenuwhen an item is selected.
- bool hide_on_state_item_selection
true, hides thePopupMenuwhen a state item is selected.
- float submenu_popup_delay
Sets the delay time in seconds for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item.
Method Descriptions
- add_check_item ( String label, int id=-1, int accel=0 )
label.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )
ShortCut to it. Sets the label of the checkbox to the ShortCut‘s name.
idcan optionally be provided. If noidis provided, one will be created from the index. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_icon_check_item ( Texture texture, String label, int id=-1, int accel=0 )
labeland icontexture.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_icon_check_shortcut ( Texture texture, ShortCut shortcut, int id=-1, bool global=false )
ShortCut and icon
textureto it. Sets the label of the checkbox to the ShortCut‘s name.idcan optionally be provided. If noidis provided, one will be created from the index. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_icon_item ( Texture texture, String label, int id=-1, int accel=0 )
labeland icontexture.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators.
- add_icon_radio_check_item ( Texture texture, String label, int id=-1, int accel=0 ) add_icon_check_item, but uses a radio check button.
- add_icon_radio_check_shortcut ( Texture texture, ShortCut shortcut, int id=-1, bool global=false ) add_icon_check_shortcut, but uses a radio check button.
- add_icon_shortcut ( Texture texture, ShortCut shortcut, int id=-1, bool global=false )
ShortCut and icon
textureto it. Sets the label of the checkbox to the ShortCut‘s name.idcan optionally be provided. If noidis provided, one will be created from the index.
- add_item ( String label, int id=-1, int accel=0 )
label.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators.
- add_multistate_item ( String label, int max_states, int default_state=0, int id=-1, int accel=0 )
label.max_states. Each press or activate of the item will increase the state by one. The default value is defined bydefault_state.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators.
- add_radio_check_item ( String label, int id=-1, int accel=0 )
label.idcan optionally be provided, as well as an accelerator (accel). If noidis provided, one will be created from the index. If noaccelis provided then the default0will be assigned to it. See get_item_accelerator for more info on accelerators. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_radio_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )
ShortCut to it. Sets the label of the checkbox to the ShortCut‘s name.
idcan optionally be provided. If noidis provided, one will be created from the index. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See set_item_checked for more info on how to control it.
- add_separator ( String label=””, int id=-1 )
idparameter.labelcan optionally be provided, which will appear at the center of the separator.
- add_shortcut ( ShortCut shortcut, int id=-1, bool global=false )
ShortCut.
idcan optionally be provided. If noidis provided, one will be created from the index.
- add_submenu_item ( String label, String submenu, int id=-1 )
PopupMenunode when clicked. Thesubmenuargument is the name of the childPopupMenunode that will be shown when the item is clicked.idcan optionally be provided. If noidis provided, one will be created from the index.
- clear ( )
PopupMenu.
- int get_current_index ( ) const
-1if no item is focused.
- int get_item_accelerator ( int idx ) const
idx. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
- int get_item_count ( ) const
PopupMenu.
- Texture get_item_icon ( int idx ) const
idx.
- int get_item_id ( int idx ) const
idx.idcan be manually assigned, while index can not.
- int get_item_index ( int id ) const
id. Index is automatically assigned to each item by the engine. Index can not be set manually.
- Variant get_item_metadata ( int idx ) const set_item_metadata, which provides a simple way of assigning context data to items.
- ShortCut get_item_shortcut ( int idx ) const
ShortCut associated with the specified
idxitem.
- String get_item_submenu ( int idx ) const
idx. See add_submenu_item for more info on how to add a submenu.
- String get_item_text ( int idx ) const
idx.
- String get_item_tooltip ( int idx ) const
idx.
- bool is_hide_on_window_lose_focus ( ) const
trueif the popup will be hidden when the window loses focus or not.
- bool is_item_checkable ( int idx ) const
trueif the item at indexidxis checkable in some way, i.e. if it has a checkbox or radio button. Note: Checkable items just display a checkmark or radio button, but don’t have any built-in checking behavior and must be checked/unchecked manually.
- bool is_item_checked ( int idx ) const
trueif the item at indexidxis checked.
- bool is_item_disabled ( int idx ) const
trueif the item at indexidxis disabled. When it is disabled it can’t be selected, or its action invoked. set_item_disabled for more info on how to disable an item.
- bool is_item_radio_checkable ( int idx ) const
trueif the item at indexidxhas radio button-style checkability. Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
- bool is_item_separator ( int idx ) const
trueif the item is a separator. If it is, it will be displayed as a line. See add_separator for more info on how to add a separator.
- bool is_item_shortcut_disabled ( int idx ) const
trueif the specified item’s shortcut is disabled.
- remove_item ( int idx )
idxfrom the menu. Note: The indices of items after the removed item will be shifted by one.
- set_hide_on_window_lose_focus ( bool enable )
PopupMenuwhen the window loses focus.
- set_item_accelerator ( int idx, int accel )
idx. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
- set_item_as_checkable ( int idx, bool enable )
idxhas a checkbox. Iffalse, sets the type of the item to plain text. Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually.
- set_item_as_radio_checkable ( int idx, bool enable )
idxto radio button. Iffalse, sets the type of the item to plain text.
- set_item_as_separator ( int idx, bool enable )
idxas a separator, which means that it would be displayed as a line. Iffalse, sets the type of the item to plain text.
- set_item_checked ( int idx, bool checked )
idx.
- set_item_disabled ( int idx, bool disabled )
idx. When it is disabled, it can’t be selected and its action can’t be invoked.
- set_item_icon ( int idx, Texture icon )
Texture icon of the specified
idx.
- set_item_id ( int idx, int id )
idof the item at indexidx.
- set_item_metadata ( int idx, Variant metadata ) get_item_metadata, which provides a simple way of assigning context data to items.
- set_item_multistate ( int idx, int state ) add_multistate_item for details.
- set_item_shortcut ( int idx, ShortCut shortcut, bool global=false )
ShortCut for the specified item
idx.
- set_item_shortcut_disabled ( int idx, bool disabled )
ShortCut of the specified index
idx.
- set_item_submenu ( int idx, String submenu )
idx. The submenu is the name of a childPopupMenunode that would be shown when the item is clicked.
- set_item_text ( int idx, String text )
idx.
- set_item_tooltip ( int idx, String tooltip )
String tooltip of the item at the specified index
idx.
- toggle_item_checked ( int idx )
idx.
- toggle_item_multistate ( int idx )
add_multistate_item for details.
Theme Property Descriptions
- Texture checked Texture icon for the checked checkbox items.
- Font font Font used for the menu items.
- Color font_color Color for menu items’ names.
- Color font_color_accel Color used for shortcuts and accelerators that show next to the menu item name when defined. See get_item_accelerator for more info on accelerators.
- Color font_color_disabled Color used for disabled menu items’ text.
- Color font_color_hover Color used for the hovered text.
- Color font_color_separator Color used for labeled separators’ text. See add_separator.
- StyleBox hover
StyleBox displayed when the
PopupMenuitem is hovered.
- int hseparation The horizontal space between the item’s name and the shortcut text/submenu arrow.
- StyleBox labeled_separator_left StyleBox for the left side of labeled separator. See add_separator.
- StyleBox labeled_separator_right StyleBox for the right side of labeled separator. See add_separator.
- StyleBox panel
StyleBox of the
PopupMenuitems.
- StyleBox panel_disabled
StyleBox used when the
PopupMenuitem is disabled.
- Texture radio_checked Texture icon for the checked radio button items.
- Texture radio_unchecked Texture icon for the unchecked radio button items.
- StyleBox separator StyleBox used for the separators. See add_separator.
- Texture submenu Texture icon for the submenu arrow.
- Texture unchecked Texture icon for the unchecked checkbox items.
- int vseparation The vertical space between each menu item.
