MenuButton

Refreshing Cache...

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 items new properties.

Properties

ActionModeaction_modeO: 0
FocusModeenabled_focus_modeO: 0
boolflatO: true
FocusModefocus_modeO: 0
boolswitch_on_hoverfalse
booltoggle_modeO: true

Methods

PopupMenuget_popup ( ) const
voidset_disable_shortcuts ( bool disabled )

Theme Properties

StyleBoxdisabled 
StyleBoxfocus 
Fontfont 
Colorfont_colorColor( 0.88, 0.88, 0.88, 1 )
Colorfont_color_disabledColor( 1, 1, 1, 0.3 )
Colorfont_color_hoverColor( 0.94, 0.94, 0.94, 1 )
Colorfont_color_pressedColor( 1, 1, 1, 1 )
StyleBoxhover 
inthseparation3
StyleBoxnormal 
StyleBoxpressed 

Signals

  • about_to_show ( )

Emitted when PopupMenu of this MenuButton is about to show.

Property Descriptions

  • bool switch_on_hover
Defaultfalse
Setterset_switch_on_hover(value)
Getteris_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.


  • void set_disable_shortcuts ( bool disabled )

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

doradoro's advice! Getters and Setters will be deprecated! Avoid their use!

Disclaimer: This page has been automaticaly and directly extracted from the official Godot Docs website, the 2020-03-07 at 01:34:31. It's the English Stable version because it's what most Godot users should use. The Copyright owners are Juan Linietsky, Ariel Manzur and the Godot community. CC-BY 3.0. Thanks for your patience and generosity.