2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 14:18:53 +01:00
<class name= "MenuButton" inherits= "Button" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 22:42:36 +02:00
<brief_description >
Special button that brings up a [PopupMenu] when clicked.
</brief_description>
<description >
2020-01-23 11:14:14 +01:00
Special button that brings up a [PopupMenu] when clicked.
2021-03-18 12:04:28 +01:00
New items can be created inside this [PopupMenu] using [code]get_popup().add_item("My Item Name")[/code]. 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 [b]Items[/b] then click [b]Add[/b] in the popup. You will be able to give each item new properties.
2020-09-23 23:34:28 +02:00
See also [BaseButton] which contains common properties and methods associated with this node.
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
</tutorials>
<methods >
2017-12-25 17:03:53 +01:00
<method name= "get_popup" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "PopupMenu" />
2017-09-12 22:42:36 +02:00
<description >
2019-05-24 04:15:43 +02:00
Returns the [PopupMenu] contained in this button.
2021-10-10 21:28:56 +02:00
[b]Warning:[/b] 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 [member Window.visible] property.
2017-09-12 22:42:36 +02:00
</description>
</method>
2018-01-03 13:45:03 +01:00
<method name= "set_disable_shortcuts" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "disabled" type= "bool" />
2018-01-03 13:45:03 +01:00
<description >
2020-01-23 11:14:14 +01:00
If [code]true[/code], shortcuts are disabled and cannot be used to trigger the button.
2018-01-03 13:45:03 +01:00
</description>
</method>
2022-10-02 08:46:37 +02:00
<method name= "show_popup" >
<return type= "void" />
<description >
Adjusts popup position and sizing for the [MenuButton], then shows the [PopupMenu]. Prefer this over using [code]get_popup().popup()[/code].
</description>
</method>
2017-09-12 22:42:36 +02:00
</methods>
2018-07-30 00:26:43 +02:00
<members >
2021-12-02 20:38:49 +01:00
<member name= "action_mode" type= "int" setter= "set_action_mode" getter= "get_action_mode" overrides= "BaseButton" enum= "BaseButton.ActionMode" default= "0" />
<member name= "flat" type= "bool" setter= "set_flat" getter= "is_flat" overrides= "Button" default= "true" />
<member name= "focus_mode" type= "int" setter= "set_focus_mode" getter= "get_focus_mode" overrides= "Control" enum= "Control.FocusMode" default= "0" />
2021-12-07 04:09:31 +01:00
<member name= "item_count" type= "int" setter= "set_item_count" getter= "get_item_count" default= "0" >
2021-11-03 03:08:58 +01:00
The number of items currently in the list.
</member>
2019-06-29 12:38:01 +02:00
<member name= "switch_on_hover" type= "bool" setter= "set_switch_on_hover" getter= "is_switch_on_hover" default= "false" >
2020-01-23 11:14:14 +01:00
If [code]true[/code], when the cursor hovers above another [MenuButton] within the same parent which also has [code]switch_on_hover[/code] enabled, it will close the current [MenuButton] and open the other one.
2018-07-30 00:26:43 +02:00
</member>
2021-12-02 20:38:49 +01:00
<member name= "toggle_mode" type= "bool" setter= "set_toggle_mode" getter= "is_toggle_mode" overrides= "BaseButton" default= "true" />
2018-07-30 00:26:43 +02:00
</members>
2017-09-12 22:42:36 +02:00
<signals >
2020-03-31 11:56:58 +02:00
<signal name= "about_to_popup" >
2017-09-12 22:42:36 +02:00
<description >
2020-03-31 11:56:58 +02:00
Emitted when the [PopupMenu] of this MenuButton is about to show.
2017-09-12 22:42:36 +02:00
</description>
</signal>
</signals>
<theme_items >
2021-12-30 17:22:06 +01:00
<theme_item name= "font_color" data_type= "color" type= "Color" default= "Color(0.875, 0.875, 0.875, 1)" >
2020-02-04 08:46:01 +01:00
Default text [Color] of the [MenuButton].
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_disabled_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 0.3)" >
2020-02-04 08:46:01 +01:00
Text [Color] used when the [MenuButton] is disabled.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-12-30 17:22:06 +01:00
<theme_item name= "font_focus_color" data_type= "color" type= "Color" default= "Color(0.95, 0.95, 0.95, 1)" >
2021-10-26 16:28:12 +02:00
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.
</theme_item>
2021-12-30 17:22:06 +01:00
<theme_item name= "font_hover_color" data_type= "color" type= "Color" default= "Color(0.95, 0.95, 0.95, 1)" >
2020-02-04 08:46:01 +01:00
Text [Color] used when the [MenuButton] is being hovered.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_outline_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-12-25 22:45:28 +01:00
The tint of text outline of the [MenuButton].
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-02-04 08:46:01 +01:00
Text [Color] used when the [MenuButton] is being pressed.
2017-09-12 22:42:36 +02:00
</theme_item>
2022-04-14 23:20:28 +02:00
<theme_item name= "h_separation" data_type= "constant" type= "int" default= "3" >
2022-08-12 13:39:22 +02:00
The horizontal space between [MenuButton]'s icon and text. Negative values will be treated as [code]0[/code] when used.
2021-12-01 19:02:20 +01:00
</theme_item>
<theme_item name= "outline_size" data_type= "constant" type= "int" default= "0" >
The size of the text outline.
2022-12-19 17:15:44 +01:00
[b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
2021-12-01 19:02:20 +01:00
</theme_item>
<theme_item name= "font" data_type= "font" type= "Font" >
[Font] of the [MenuButton]'s text.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_size" data_type= "font_size" type= "int" >
2020-08-12 13:49:10 +02:00
Font size of the [MenuButton]'s text.
</theme_item>
2021-12-01 19:02:20 +01:00
<theme_item name= "disabled" data_type= "style" type= "StyleBox" >
[StyleBox] used when the [MenuButton] is disabled.
</theme_item>
<theme_item name= "focus" data_type= "style" type= "StyleBox" >
2021-11-20 17:43:34 +01:00
[StyleBox] used when the [MenuButton] is focused. The [code]focus[/code] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
2021-12-01 19:02:20 +01:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "hover" data_type= "style" type= "StyleBox" >
2020-02-04 08:46:01 +01:00
[StyleBox] used when the [MenuButton] is being hovered.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "normal" data_type= "style" type= "StyleBox" >
2020-02-04 08:46:01 +01:00
Default [StyleBox] for the [MenuButton].
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "pressed" data_type= "style" type= "StyleBox" >
2020-02-04 08:46:01 +01:00
[StyleBox] used when the [MenuButton] is being pressed.
2017-09-12 22:42:36 +02:00
</theme_item>
</theme_items>
</class>