summaryrefslogtreecommitdiff
path: root/doc/classes/Control.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/Control.xml')
-rw-r--r--doc/classes/Control.xml256
1 files changed, 122 insertions, 134 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 75d5a72fb1..9dbb843902 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="Control" inherits="CanvasItem" category="Core" version="3.2">
+<class name="Control" inherits="CanvasItem" version="4.0">
<brief_description>
All user interface nodes inherit from Control. A control's anchors and margins adapt its position and size relative to its parent.
</brief_description>
@@ -7,10 +7,12 @@
Base class for all UI-related nodes. [Control] features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change.
For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [Control] and [Container] nodes.
[b]User Interface nodes and input[/b]
- Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [method MainLoop._input_event]. Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it.
+ Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [code]MainLoop._input_event[/code].
+ [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring.
+ Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it.
Only one [Control] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call [method grab_focus]. [Control] nodes lose focus when another node grabs it, or if you hide the node in focus.
Sets [member mouse_filter] to [constant MOUSE_FILTER_IGNORE] to tell a [Control] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.
- [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_*_override[/code] methods, like [method add_font_override]. You can override the theme with the inspector.
+ [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_theme_*_override[/code] methods, like [method add_theme_font_override]. You can override the theme with the inspector.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/gui/index.html</link>
@@ -87,10 +89,10 @@
Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input].
</description>
</method>
- <method name="add_color_override">
+ <method name="add_theme_color_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="color" type="Color">
</argument>
@@ -98,10 +100,10 @@
Overrides the [Color] with given [code]name[/code] in the [member theme] resource the control uses. If the [code]color[/code] is empty or invalid, the override is cleared and the color from assigned [Theme] is used.
</description>
</method>
- <method name="add_constant_override">
+ <method name="add_theme_constant_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="constant" type="int">
</argument>
@@ -109,10 +111,10 @@
Overrides an integer constant with given [code]name[/code] in the [member theme] resource the control uses. If the [code]constant[/code] is empty or invalid, the override is cleared and the constant from assigned [Theme] is used.
</description>
</method>
- <method name="add_font_override">
+ <method name="add_theme_font_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="font" type="Font">
</argument>
@@ -120,21 +122,21 @@
Overrides the font with given [code]name[/code] in the [member theme] resource the control uses. If [code]font[/code] is empty or invalid, the override is cleared and the font from assigned [Theme] is used.
</description>
</method>
- <method name="add_icon_override">
+ <method name="add_theme_icon_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="texture" type="Texture">
+ <argument index="1" name="texture" type="Texture2D">
</argument>
<description>
Overrides the icon with given [code]name[/code] in the [member theme] resource the control uses. If [code]icon[/code] is empty or invalid, the override is cleared and the icon from assigned [Theme] is used.
</description>
</method>
- <method name="add_shader_override">
+ <method name="add_theme_shader_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="shader" type="Shader">
</argument>
@@ -142,10 +144,10 @@
Overrides the [Shader] with given [code]name[/code] in the [member theme] resource the control uses. If [code]shader[/code] is empty or invalid, the override is cleared and the shader from assigned [Theme] is used.
</description>
</method>
- <method name="add_stylebox_override">
+ <method name="add_theme_stylebox_override">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="stylebox" type="StyleBox">
</argument>
@@ -217,21 +219,6 @@
Returns [member margin_left] and [member margin_top]. See also [member rect_position].
</description>
</method>
- <method name="get_color" qualifiers="const">
- <return type="Color">
- </return>
- <argument index="0" name="name" type="String">
- </argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
- </argument>
- <description>
- Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
- [codeblock]
- func _ready():
- modulate = get_color("font_color", "Button") #get the color defined for button fonts
- [/codeblock]
- </description>
- </method>
<method name="get_combined_minimum_size" qualifiers="const">
<return type="Vector2">
</return>
@@ -239,17 +226,6 @@
Returns combined minimum size from [member rect_min_size] and [method get_minimum_size].
</description>
</method>
- <method name="get_constant" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="name" type="String">
- </argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
- </argument>
- <description>
- Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
- </description>
- </method>
<method name="get_cursor_shape" qualifiers="const">
<return type="int" enum="Control.CursorShape">
</return>
@@ -298,17 +274,6 @@
Returns the control that has the keyboard focus or [code]null[/code] if none.
</description>
</method>
- <method name="get_font" qualifiers="const">
- <return type="Font">
- </return>
- <argument index="0" name="name" type="String">
- </argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
- </argument>
- <description>
- Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
- </description>
- </method>
<method name="get_global_rect" qualifiers="const">
<return type="Rect2">
</return>
@@ -316,17 +281,6 @@
Returns the position and size of the control relative to the top-left corner of the screen. See [member rect_position] and [member rect_size].
</description>
</method>
- <method name="get_icon" qualifiers="const">
- <return type="Texture">
- </return>
- <argument index="0" name="name" type="String">
- </argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
- </argument>
- <description>
- Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
- </description>
- </method>
<method name="get_margin" qualifiers="const">
<return type="float">
</return>
@@ -371,12 +325,60 @@
Returns the rotation (in radians).
</description>
</method>
- <method name="get_stylebox" qualifiers="const">
+ <method name="get_theme_color" qualifiers="const">
+ <return type="Color">
+ </return>
+ <argument index="0" name="name" type="StringName">
+ </argument>
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
+ </argument>
+ <description>
+ Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
+ [codeblock]
+ func _ready():
+ modulate = get_theme_color("font_color", "Button") #get the color defined for button fonts
+ [/codeblock]
+ </description>
+ </method>
+ <method name="get_theme_constant" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="name" type="StringName">
+ </argument>
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
+ </argument>
+ <description>
+ Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
+ </description>
+ </method>
+ <method name="get_theme_font" qualifiers="const">
+ <return type="Font">
+ </return>
+ <argument index="0" name="name" type="StringName">
+ </argument>
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
+ </argument>
+ <description>
+ Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
+ </description>
+ </method>
+ <method name="get_theme_icon" qualifiers="const">
+ <return type="Texture2D">
+ </return>
+ <argument index="0" name="name" type="StringName">
+ </argument>
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
+ </argument>
+ <description>
+ Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
+ </description>
+ </method>
+ <method name="get_theme_stylebox" qualifiers="const">
<return type="StyleBox">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns a [StyleBox] from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code].
@@ -409,128 +411,128 @@
Steal the focus from another control and become the focused control (see [member focus_mode]).
</description>
</method>
- <method name="has_color" qualifiers="const">
+ <method name="has_focus" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <description>
+ Returns [code]true[/code] if this is the current focused control. See [member focus_mode].
+ </description>
+ </method>
+ <method name="has_point" qualifiers="virtual">
+ <return type="bool">
+ </return>
+ <argument index="0" name="point" type="Vector2">
+ </argument>
+ <description>
+ Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control.
+ If not overridden, default behavior is checking if the point is within control's Rect.
+ [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code].
+ </description>
+ </method>
+ <method name="has_theme_color" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns [code]true[/code] if [Color] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme].
</description>
</method>
- <method name="has_color_override" qualifiers="const">
+ <method name="has_theme_color_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if [Color] with given [code]name[/code] has a valid override in this [Control] node.
</description>
</method>
- <method name="has_constant" qualifiers="const">
+ <method name="has_theme_constant" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns [code]true[/code] if constant with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme].
</description>
</method>
- <method name="has_constant_override" qualifiers="const">
+ <method name="has_theme_constant_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if constant with given [code]name[/code] has a valid override in this [Control] node.
</description>
</method>
- <method name="has_focus" qualifiers="const">
+ <method name="has_theme_font" qualifiers="const">
<return type="bool">
</return>
- <description>
- Returns [code]true[/code] if this is the current focused control. See [member focus_mode].
- </description>
- </method>
- <method name="has_font" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns [code]true[/code] if font with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme].
</description>
</method>
- <method name="has_font_override" qualifiers="const">
+ <method name="has_theme_font_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if font with given [code]name[/code] has a valid override in this [Control] node.
</description>
</method>
- <method name="has_icon" qualifiers="const">
+ <method name="has_theme_icon" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns [code]true[/code] if icon with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme].
</description>
</method>
- <method name="has_icon_override" qualifiers="const">
+ <method name="has_theme_icon_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if icon with given [code]name[/code] has a valid override in this [Control] node.
</description>
</method>
- <method name="has_point" qualifiers="virtual">
- <return type="bool">
- </return>
- <argument index="0" name="point" type="Vector2">
- </argument>
- <description>
- Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control.
- If not overridden, default behavior is checking if the point is within control's Rect.
- [b]Node:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code].
- </description>
- </method>
- <method name="has_shader_override" qualifiers="const">
+ <method name="has_theme_shader_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if [Shader] with given [code]name[/code] has a valid override in this [Control] node.
</description>
</method>
- <method name="has_stylebox" qualifiers="const">
+ <method name="has_theme_stylebox" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="type" type="String" default="&quot;&quot;">
+ <argument index="1" name="type" type="StringName" default="&quot;&quot;">
</argument>
<description>
Returns [code]true[/code] if [StyleBox] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme].
</description>
</method>
- <method name="has_stylebox_override" qualifiers="const">
+ <method name="has_theme_stylebox_override" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if [StyleBox] with given [code]name[/code] has a valid override in this [Control] node.
@@ -757,16 +759,6 @@
If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins.
</description>
</method>
- <method name="show_modal">
- <return type="void">
- </return>
- <argument index="0" name="exclusive" type="bool" default="false">
- </argument>
- <description>
- Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus.
- If [code]exclusive[/code] is [code]true[/code], other controls will not receive input and clicking outside this control will not close it.
- </description>
- </method>
<method name="warp_mouse">
<return type="void">
</return>
@@ -806,11 +798,11 @@
Tells Godot which node it should give keyboard focus to if the user presses the top arrow on the keyboard or top on a gamepad by default. You can change the key by editing the [code]ui_top[/code] input action. The node must be a [Control]. If this property is not set, Godot will give focus to the closest [Control] to the bottom of this one.
</member>
<member name="focus_next" type="NodePath" setter="set_focus_next" getter="get_focus_next" default="NodePath(&quot;&quot;)">
- Tells Godot which node it should give keyboard focus to if the user presses Tab on a keyboard by default. You can change the key by editing the [code]ui_focus_next[/code] input action.
+ Tells Godot which node it should give keyboard focus to if the user presses [kbd]Tab[/kbd] on a keyboard by default. You can change the key by editing the [code]ui_focus_next[/code] input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
</member>
<member name="focus_previous" type="NodePath" setter="set_focus_previous" getter="get_focus_previous" default="NodePath(&quot;&quot;)">
- Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab on a keyboard by default. You can change the key by editing the [code]ui_focus_prev[/code] input action.
+ Tells Godot which node it should give keyboard focus to if the user presses [kbd]Shift + Tab[/kbd] on a keyboard by default. You can change the key by editing the [code]ui_focus_prev[/code] input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
</member>
<member name="grow_horizontal" type="int" setter="set_h_grow_direction" getter="get_h_grow_direction" enum="Control.GrowDirection" default="1">
@@ -846,7 +838,7 @@
Controls whether the control will be able to receive mouse button input events through [method _gui_input] and how these events should be handled. Also controls whether the control can receive the [signal mouse_entered], and [signal mouse_exited] signals. See the constants to learn what each does.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" default="false">
- Enables whether rendering of children should be clipped to this control's rectangle. If [code]true[/code], parts of a child which would be visibly outside of this control's rectangle will not be rendered.
+ Enables whether rendering of [CanvasItem] based children should be clipped to this control's rectangle. If [code]true[/code], parts of a child which would be visibly outside of this control's rectangle will not be rendered.
</member>
<member name="rect_global_position" type="Vector2" setter="_set_global_position" getter="get_global_position">
The node's global position, relative to the world (usually to the top-left corner of the window).
@@ -905,11 +897,6 @@
Emitted when the node's minimum size changes.
</description>
</signal>
- <signal name="modal_closed">
- <description>
- Emitted when a modal [Control] is closed. See [method show_modal].
- </description>
- </signal>
<signal name="mouse_entered">
<description>
Emitted when the mouse enters the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it.
@@ -930,6 +917,10 @@
Emitted when one of the size flags changes. See [member size_flags_horizontal] and [member size_flags_vertical].
</description>
</signal>
+ <signal name="theme_changed">
+ <description>
+ </description>
+ </signal>
</signals>
<constants>
<constant name="FOCUS_NONE" value="0" enum="FocusMode">
@@ -957,10 +948,7 @@
Sent when the node loses focus.
</constant>
<constant name="NOTIFICATION_THEME_CHANGED" value="45">
- Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_*_override[/code] methods.
- </constant>
- <constant name="NOTIFICATION_MODAL_CLOSE" value="46">
- Sent when an open modal dialog closes. See [method show_modal].
+ Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_theme_*_override[/code] methods.
</constant>
<constant name="NOTIFICATION_SCROLL_BEGIN" value="47">
Sent when this node is inside a [ScrollContainer] which has begun being scrolled.