MenuButton

Inherits: Button < BaseButton < Control < CanvasItem < Node < Object

Special button that brings up a PopupMenu when clicked.

Description

Special button that brings up a PopupMenu when clicked.

New items can be created inside this PopupMenu using get_popup().add_item("My Item Name"). You can also create them directly from the editor. To do so, select the MenuButton node, then in the toolbar at the top of the 2D editor, click Items then click Add in the popup. You will be able to give each item new properties.

See also BaseButton which contains common properties and methods associated with this node.

Properties

ActionMode

action_mode

0 (parent override)

bool

flat

true (parent override)

FocusMode

focus_mode

0 (parent override)

bool

switch_on_hover

false

bool

toggle_mode

true (parent override)

Methods

PopupMenu

get_popup ( ) const

void

set_disable_shortcuts ( bool disabled )

Theme Properties

StyleBox

disabled

StyleBox

focus

Font

font

Color

font_color

Color( 0.88, 0.88, 0.88, 1 )

Color

font_color_disabled

Color( 1, 1, 1, 0.3 )

Color

font_color_focus

Color( 0.94, 0.94, 0.94, 1 )

Color

font_color_hover

Color( 0.94, 0.94, 0.94, 1 )

Color

font_color_pressed

Color( 1, 1, 1, 1 )

StyleBox

hover

int

hseparation

3

StyleBox

normal

StyleBox

pressed

Signals

  • about_to_show ( )

Emitted when PopupMenu of this MenuButton is about to show.

Property Descriptions

  • bool switch_on_hover

Default

false

Setter

set_switch_on_hover(value)

Getter

is_switch_on_hover()

If true, when the cursor hovers above another MenuButton within the same parent which also has switch_on_hover enabled, it will close the current MenuButton and open the other one.

Method Descriptions

Returns the PopupMenu contained in this button.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.


  • void set_disable_shortcuts ( bool disabled )

If true, shortcuts are disabled and cannot be used to trigger the button.

Theme Property Descriptions

StyleBox used when the MenuButton is disabled.


StyleBox used when the MenuButton is focused. It is displayed over the current StyleBox, so using StyleBoxEmpty will just disable the focus visual effect.


Font of the MenuButton‘s text.


Default

Color( 0.88, 0.88, 0.88, 1 )

Default text Color of the MenuButton.


  • Color font_color_disabled

Default

Color( 1, 1, 1, 0.3 )

Text Color used when the MenuButton is disabled.


Default

Color( 0.94, 0.94, 0.94, 1 )

Text Color used when the MenuButton is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.


Default

Color( 0.94, 0.94, 0.94, 1 )

Text Color used when the MenuButton is being hovered.


  • Color font_color_pressed

Default

Color( 1, 1, 1, 1 )

Text Color used when the MenuButton is being pressed.


StyleBox used when the MenuButton is being hovered.


  • int hseparation

Default

3

The horizontal space between MenuButton‘s icon and text.


Default StyleBox for the MenuButton.


StyleBox used when the MenuButton is being pressed.