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.xml876
1 files changed, 371 insertions, 505 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index a9a230b78f..6602764cd4 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -9,7 +9,7 @@
[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 [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.
+ Call [method accept_event] so no other node receives the event. Once you accept 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_theme_*_override[/code] methods, like [method add_theme_font_override]. You can override the theme with the inspector.
@@ -22,27 +22,91 @@
<link title="All GUI Demos">https://github.com/godotengine/godot-demo-projects/tree/master/gui</link>
</tutorials>
<methods>
- <method name="_clips_input" qualifiers="virtual">
- <return type="bool">
- </return>
+ <method name="_can_drop_data" qualifiers="virtual const">
+ <return type="bool" />
+ <argument index="0" name="at_position" type="Vector2" />
+ <argument index="1" name="data" type="Variant" />
<description>
- Virtual method to be implemented by the user. Returns whether [method _gui_input] should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this [Control]. Similar to [member rect_clip_content], but doesn't affect visibility.
- If not overridden, defaults to [code]false[/code].
+ Godot calls this method to test if [code]data[/code] from a control's [method _get_drag_data] can be dropped at [code]position[/code]. [code]position[/code] is local to this control.
+ This method should only be used to test the data. Process the data in [method _drop_data].
+ [codeblocks]
+ [gdscript]
+ func _can_drop_data(position, data):
+ # Check position if it is relevant to you
+ # Otherwise, just check data
+ return typeof(data) == TYPE_DICTIONARY and data.has("expected")
+ [/gdscript]
+ [csharp]
+ public override bool CanDropData(Vector2 position, object data)
+ {
+ // Check position if it is relevant to you
+ // Otherwise, just check data
+ return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("expected");
+ }
+ [/csharp]
+ [/codeblocks]
</description>
</method>
- <method name="_get_minimum_size" qualifiers="virtual">
- <return type="Vector2">
- </return>
+ <method name="_drop_data" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="at_position" type="Vector2" />
+ <argument index="1" name="data" type="Variant" />
+ <description>
+ Godot calls this method to pass you the [code]data[/code] from a control's [method _get_drag_data] result. Godot first calls [method _can_drop_data] to test if [code]data[/code] is allowed to drop at [code]position[/code] where [code]position[/code] is local to this control.
+ [codeblocks]
+ [gdscript]
+ func _can_drop_data(position, data):
+ return typeof(data) == TYPE_DICTIONARY and data.has("color")
+ func _drop_data(position, data):
+ var color = data["color"]
+ [/gdscript]
+ [csharp]
+ public override bool CanDropData(Vector2 position, object data)
+ {
+ return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("color");
+ }
+ public override void DropData(Vector2 position, object data)
+ {
+ Color color = (Color)(data as Godot.Collections.Dictionary)["color"];
+ }
+ [/csharp]
+ [/codeblocks]
+ </description>
+ </method>
+ <method name="_get_drag_data" qualifiers="virtual const">
+ <return type="Variant" />
+ <argument index="0" name="at_position" type="Vector2" />
+ <description>
+ Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns [code]null[/code] if there is no data to drag. Controls that want to receive drop data should implement [method _can_drop_data] and [method _drop_data]. [code]position[/code] is local to this control. Drag may be forced with [method force_drag].
+ A preview that will follow the mouse that should represent the data can be set with [method set_drag_preview]. A good time to set the preview is in this method.
+ [codeblocks]
+ [gdscript]
+ func _get_drag_data(position):
+ var mydata = make_data() # This is your custom method generating the drag data.
+ set_drag_preview(make_preview(mydata)) # This is your custom method generating the preview of the drag data.
+ return mydata
+ [/gdscript]
+ [csharp]
+ public override object GetDragData(Vector2 position)
+ {
+ object mydata = MakeData(); // This is your custom method generating the drag data.
+ SetDragPreview(MakePreview(mydata)); // This is your custom method generating the preview of the drag data.
+ return mydata;
+ }
+ [/csharp]
+ [/codeblocks]
+ </description>
+ </method>
+ <method name="_get_minimum_size" qualifiers="virtual const">
+ <return type="Vector2" />
<description>
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to [member rect_min_size] for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately).
If not overridden, defaults to [constant Vector2.ZERO].
</description>
</method>
<method name="_gui_input" qualifiers="virtual">
- <return type="void">
- </return>
- <argument index="0" name="event" type="InputEvent">
- </argument>
+ <return type="void" />
+ <argument index="0" name="event" type="InputEvent" />
<description>
Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See [method accept_event].
Example: clicking a control.
@@ -68,24 +132,31 @@
[/csharp]
[/codeblocks]
The event won't trigger if:
- * clicking outside the control (see [method has_point]);
+ * clicking outside the control (see [method _has_point]);
* control has [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE];
* control is obstructed by another [Control] on top of it, which doesn't have [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE];
* control's parent has [member mouse_filter] set to [constant MOUSE_FILTER_STOP] or has accepted the event;
- * it happens outside parent's rectangle and the parent has either [member rect_clip_content] or [method _clips_input] enabled.
+ * it happens outside the parent's rectangle and the parent has either [member rect_clip_content] enabled.
</description>
</method>
- <method name="_make_custom_tooltip" qualifiers="virtual">
- <return type="Control">
- </return>
- <argument index="0" name="for_text" type="String">
- </argument>
+ <method name="_has_point" qualifiers="virtual const">
+ <return type="bool" />
+ <argument index="0" name="position" type="Vector2" />
+ <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="_make_custom_tooltip" qualifiers="virtual const">
+ <return type="Object" />
+ <argument index="0" name="for_text" type="String" />
<description>
Virtual method to be implemented by the user. Returns a [Control] node that should be used as a tooltip instead of the default one. The [code]for_text[/code] includes the contents of the [member hint_tooltip] property.
- The returned node must be of type [Control] or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance).When [code]null[/code] or a non-Control node is returned, the default tooltip will be used instead.
+ The returned node must be of type [Control] or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance). When [code]null[/code] or a non-Control node is returned, the default tooltip will be used instead.
The returned node will be added as child to a [PopupPanel], so you should only provide the contents of that panel. That [PopupPanel] can be themed using [method Theme.set_stylebox] for the type [code]"TooltipPanel"[/code] (see [member hint_tooltip] for an example).
[b]Note:[/b] The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its [member rect_min_size] to some non-zero value.
- [b]Note:[/b] The node (and any relevant children) should be [member CanvasItem.visible] when returned, otherwise the viewport that instantiates it will not be able to calculate its minimum size reliably.
+ [b]Note:[/b] The node (and any relevant children) should be [member CanvasItem.visible] when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably.
Example of usage with a custom-constructed node:
[codeblocks]
[gdscript]
@@ -107,14 +178,14 @@
[codeblocks]
[gdscript]
func _make_custom_tooltip(for_text):
- var tooltip = preload("res://SomeTooltipScene.tscn").instance()
+ var tooltip = preload("res://SomeTooltipScene.tscn").instantiate()
tooltip.get_node("Label").text = for_text
return tooltip
[/gdscript]
[csharp]
public override Godot.Control _MakeCustomTooltip(String forText)
{
- Node tooltip = ResourceLoader.Load&lt;PackedScene&gt;("res://SomeTooltipScene.tscn").Instance();
+ Node tooltip = ResourceLoader.Load&lt;PackedScene&gt;("res://SomeTooltipScene.tscn").Instantiate();
tooltip.GetNode&lt;Label&gt;("Label").Text = forText;
return tooltip;
}
@@ -122,106 +193,92 @@
[/codeblocks]
</description>
</method>
- <method name="_structured_text_parser" qualifiers="virtual">
- <return type="void">
- </return>
- <argument index="0" name="args" type="Array">
- </argument>
- <argument index="1" name="text" type="String">
- </argument>
+ <method name="_structured_text_parser" qualifiers="virtual const">
+ <return type="Array" />
+ <argument index="0" name="args" type="Array" />
+ <argument index="1" name="text" type="String" />
<description>
User defined BiDi algorithm override function.
Return [code]Array[/code] of [code]Vector2i[/code] text ranges, in the left-to-right order. Ranges should cover full source [code]text[/code] without overlaps. BiDi algorithm will be used on each range separately.
</description>
</method>
<method name="accept_event">
- <return type="void">
- </return>
+ <return type="void" />
<description>
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_theme_color_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="color" type="Color">
- </argument>
- <description>
- Overrides the [Color] with given [code]name[/code] in the [member theme] resource the control uses.
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="color" type="Color" />
+ <description>
+ Creates a local override for a theme [Color] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_color_override].
+ See also [method get_theme_color].
[b]Example of overriding a label's color and resetting it later:[/b]
[codeblocks]
[gdscript]
- # Override the child node "MyLabel"'s font color to orange.
+ # Given the child Label node "MyLabel", override its font color with a custom value.
$MyLabel.add_theme_color_override("font_color", Color(1, 0.5, 0))
- # Reset the color by creating a new node to get the default value:
- var default_label_color = Label.new().get_theme_color("font_color")
- $MyLabel.add_theme_color_override("font_color", default_label_color)
+ # Reset the font color of the child label.
+ $MyLabel.remove_theme_color_override("font_color")
+ # Alternatively it can be overridden with the default value from the Label type.
+ $MyLabel.add_theme_color_override("font_color", get_theme_color("font_color", "Label"))
[/gdscript]
[csharp]
- // Override the child node "MyLabel"'s font color to orange.
- GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0));
- // Reset the color by creating a new node to get the default value:
- var defaultLabelColor = new Label().GetThemeColor("font_color");
- GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", defaultLabelColor);
+ // Given the child Label node "MyLabel", override its font color with a custom value.
+ GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0))
+ // Reset the font color of the child label.
+ GetNode&lt;Label&gt;("MyLabel").RemoveThemeColorOverride("font_color")
+ // Alternatively it can be overridden with the default value from the Label type.
+ GetNode&lt;Label&gt;("MyLabel").AddThemeColorOverride("font_color", GetThemeColor("font_color", "Label"))
[/csharp]
[/codeblocks]
</description>
</method>
<method name="add_theme_constant_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="constant" type="int">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="constant" type="int" />
<description>
- Overrides an integer constant with given [code]name[/code] in the [member theme] resource the control uses.
+ Creates a local override for a theme constant with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_constant_override].
+ See also [method get_theme_constant].
</description>
</method>
<method name="add_theme_font_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="font" type="Font">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="font" type="Font" />
<description>
- Overrides the font with given [code]name[/code] in the [member theme] resource the control uses.
+ Creates a local override for a theme [Font] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_override].
+ See also [method get_theme_font].
</description>
</method>
<method name="add_theme_font_size_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="font_size" type="int">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="font_size" type="int" />
<description>
- Overrides the font size with given [code]name[/code] in the [member theme] resource the control uses.
+ Creates a local override for a theme font size with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_size_override].
+ See also [method get_theme_font_size].
</description>
</method>
<method name="add_theme_icon_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="texture" type="Texture2D">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="texture" type="Texture2D" />
<description>
- Overrides the icon with given [code]name[/code] in the [member theme] resource the control uses.
+ Creates a local override for a theme icon with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_icon_override].
+ See also [method get_theme_icon].
</description>
</method>
<method name="add_theme_stylebox_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="stylebox" type="StyleBox">
- </argument>
- <description>
- Overrides the [StyleBox] with given [code]name[/code] in the [member theme] resource the control uses.
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="stylebox" type="StyleBox" />
+ <description>
+ Creates a local override for a theme [StyleBox] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_stylebox_override].
+ See also [method get_theme_stylebox].
[b]Example of modifying a property in a StyleBox by duplicating it:[/b]
[codeblocks]
[gdscript]
@@ -232,8 +289,8 @@
new_stylebox_normal.border_width_top = 3
new_stylebox_normal.border_color = Color(0, 1, 0.5)
$MyButton.add_theme_stylebox_override("normal", new_stylebox_normal)
- # Remove the stylebox override:
- $MyButton.add_theme_stylebox_override("normal", null)
+ # Remove the stylebox override.
+ $MyButton.remove_theme_stylebox_override("normal")
[/gdscript]
[csharp]
// The snippet below assumes the child node MyButton has a StyleBoxFlat assigned.
@@ -243,310 +300,208 @@
newStyleboxNormal.BorderWidthTop = 3;
newStyleboxNormal.BorderColor = new Color(0, 1, 0.5f);
GetNode&lt;Button&gt;("MyButton").AddThemeStyleboxOverride("normal", newStyleboxNormal);
- // Remove the stylebox override:
- GetNode&lt;Button&gt;("MyButton").AddThemeStyleboxOverride("normal", null);
+ // Remove the stylebox override.
+ GetNode&lt;Button&gt;("MyButton").RemoveThemeStyleboxOverride("normal");
[/csharp]
[/codeblocks]
</description>
</method>
- <method name="can_drop_data" qualifiers="virtual">
- <return type="bool">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <argument index="1" name="data" type="Variant">
- </argument>
+ <method name="begin_bulk_theme_override">
+ <return type="void" />
<description>
- Godot calls this method to test if [code]data[/code] from a control's [method get_drag_data] can be dropped at [code]position[/code]. [code]position[/code] is local to this control.
- This method should only be used to test the data. Process the data in [method drop_data].
- [codeblocks]
- [gdscript]
- func can_drop_data(position, data):
- # Check position if it is relevant to you
- # Otherwise, just check data
- return typeof(data) == TYPE_DICTIONARY and data.has("expected")
- [/gdscript]
- [csharp]
- public override bool CanDropData(Vector2 position, object data)
- {
- // Check position if it is relevant to you
- // Otherwise, just check data
- return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("expected");
- }
- [/csharp]
- [/codeblocks]
+ Prevents [code]*_theme_*_override[/code] methods from emitting [constant NOTIFICATION_THEME_CHANGED] until [method end_bulk_theme_override] is called.
</description>
</method>
- <method name="drop_data" qualifiers="virtual">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <argument index="1" name="data" type="Variant">
- </argument>
+ <method name="end_bulk_theme_override">
+ <return type="void" />
<description>
- Godot calls this method to pass you the [code]data[/code] from a control's [method get_drag_data] result. Godot first calls [method can_drop_data] to test if [code]data[/code] is allowed to drop at [code]position[/code] where [code]position[/code] is local to this control.
- [codeblocks]
- [gdscript]
- func can_drop_data(position, data):
- return typeof(data) == TYPE_DICTIONARY and data.has("color")
- func drop_data(position, data):
- var color = data["color"]
- [/gdscript]
- [csharp]
- public override bool CanDropData(Vector2 position, object data)
- {
- return data is Godot.Collections.Dictionary &amp;&amp; (data as Godot.Collections.Dictionary).Contains("color");
- }
- public override void DropData(Vector2 position, object data)
- {
- Color color = (Color)(data as Godot.Collections.Dictionary)["color"];
- }
- [/csharp]
- [/codeblocks]
+ Ends a bulk theme override update. See [method begin_bulk_theme_override].
</description>
</method>
<method name="find_next_valid_focus" qualifiers="const">
- <return type="Control">
- </return>
+ <return type="Control" />
<description>
Finds the next (below in the tree) [Control] that can receive the focus.
</description>
</method>
<method name="find_prev_valid_focus" qualifiers="const">
- <return type="Control">
- </return>
+ <return type="Control" />
<description>
Finds the previous (above in the tree) [Control] that can receive the focus.
</description>
</method>
<method name="force_drag">
- <return type="void">
- </return>
- <argument index="0" name="data" type="Variant">
- </argument>
- <argument index="1" name="preview" type="Control">
- </argument>
+ <return type="void" />
+ <argument index="0" name="data" type="Variant" />
+ <argument index="1" name="preview" type="Control" />
<description>
- Forces drag and bypasses [method get_drag_data] and [method set_drag_preview] by passing [code]data[/code] and [code]preview[/code]. Drag will start even if the mouse is neither over nor pressed on this control.
- The methods [method can_drop_data] and [method drop_data] must be implemented on controls that want to receive drop data.
+ Forces drag and bypasses [method _get_drag_data] and [method set_drag_preview] by passing [code]data[/code] and [code]preview[/code]. Drag will start even if the mouse is neither over nor pressed on this control.
+ The methods [method _can_drop_data] and [method _drop_data] must be implemented on controls that want to receive drop data.
</description>
</method>
<method name="get_anchor" qualifiers="const">
- <return type="float">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
+ <return type="float" />
+ <argument index="0" name="side" type="int" enum="Side" />
<description>
Returns the anchor for the specified [enum Side]. A getter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top].
</description>
</method>
<method name="get_begin" qualifiers="const">
- <return type="Vector2">
- </return>
+ <return type="Vector2" />
<description>
Returns [member offset_left] and [member offset_top]. See also [member rect_position].
</description>
</method>
<method name="get_combined_minimum_size" qualifiers="const">
- <return type="Vector2">
- </return>
+ <return type="Vector2" />
<description>
Returns combined minimum size from [member rect_min_size] and [method get_minimum_size].
</description>
</method>
<method name="get_cursor_shape" qualifiers="const">
- <return type="int" enum="Control.CursorShape">
- </return>
- <argument index="0" name="position" type="Vector2" default="Vector2( 0, 0 )">
- </argument>
+ <return type="int" enum="Control.CursorShape" />
+ <argument index="0" name="position" type="Vector2" default="Vector2(0, 0)" />
<description>
Returns the mouse cursor shape the control displays on mouse hover. See [enum CursorShape].
</description>
</method>
- <method name="get_drag_data" qualifiers="virtual">
- <return type="Variant">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <description>
- Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns [code]null[/code] if there is no data to drag. Controls that want to receive drop data should implement [method can_drop_data] and [method drop_data]. [code]position[/code] is local to this control. Drag may be forced with [method force_drag].
- A preview that will follow the mouse that should represent the data can be set with [method set_drag_preview]. A good time to set the preview is in this method.
- [codeblocks]
- [gdscript]
- func get_drag_data(position):
- var mydata = make_data() # This is your custom method generating the drag data.
- set_drag_preview(make_preview(mydata)) # This is your custom method generating the preview of the drag data.
- return mydata
- [/gdscript]
- [csharp]
- public override object GetDragData(Vector2 position)
- {
- object mydata = MakeData(); // This is your custom method generating the drag data.
- SetDragPreview(MakePreview(mydata)); // This is your custom method generating the preview of the drag data.
- return mydata;
- }
- [/csharp]
- [/codeblocks]
- </description>
- </method>
<method name="get_end" qualifiers="const">
- <return type="Vector2">
- </return>
+ <return type="Vector2" />
<description>
Returns [member offset_right] and [member offset_bottom].
</description>
</method>
<method name="get_focus_neighbor" qualifiers="const">
- <return type="NodePath">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
+ <return type="NodePath" />
+ <argument index="0" name="side" type="int" enum="Side" />
<description>
Returns the focus neighbor for the specified [enum Side]. A getter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top].
</description>
</method>
<method name="get_focus_owner" qualifiers="const">
- <return type="Control">
- </return>
+ <return type="Control" />
<description>
Returns the control that has the keyboard focus or [code]null[/code] if none.
</description>
</method>
<method name="get_global_rect" qualifiers="const">
- <return type="Rect2">
- </return>
+ <return type="Rect2" />
<description>
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_minimum_size" qualifiers="const">
- <return type="Vector2">
- </return>
+ <return type="Vector2" />
<description>
Returns the minimum size for this control. See [member rect_min_size].
</description>
</method>
<method name="get_offset" qualifiers="const">
- <return type="float">
- </return>
- <argument index="0" name="offset" type="int" enum="Side">
- </argument>
+ <return type="float" />
+ <argument index="0" name="offset" type="int" enum="Side" />
<description>
Returns the anchor for the specified [enum Side]. A getter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top].
</description>
</method>
<method name="get_parent_area_size" qualifiers="const">
- <return type="Vector2">
- </return>
+ <return type="Vector2" />
<description>
Returns the width/height occupied in the parent control.
</description>
</method>
<method name="get_parent_control" qualifiers="const">
- <return type="Control">
- </return>
+ <return type="Control" />
<description>
Returns the parent control node.
</description>
</method>
<method name="get_rect" qualifiers="const">
- <return type="Rect2">
- </return>
+ <return type="Rect2" />
<description>
Returns the position and size of the control relative to the top-left corner of the parent Control. See [member rect_position] and [member rect_size].
</description>
</method>
<method name="get_theme_color" qualifiers="const">
- <return type="Color">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_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]theme_type[/code].
+ <return type="Color" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
+ <description>
+ Returns a [Color] from the first matching [Theme] in the tree if that [Theme] has a color item with the specified [code]name[/code] and [code]theme_type[/code]. If [code]theme_type[/code] is omitted the class name of the current control is used as the type, or [member theme_type_variation] if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance. If the type is a variation its base types are checked, in order of dependency, then the control's class name and its parent classes are checked.
+ For the current control its local overrides are considered first (see [method add_theme_color_override]), then its assigned [member theme]. After the current control, each parent control and its assigned [member theme] are considered; controls without a [member theme] assigned are skipped. If no matching [Theme] is found in the tree, a custom project [Theme] (see [member ProjectSettings.gui/theme/custom]) and the default [Theme] are used.
[codeblocks]
[gdscript]
func _ready():
- modulate = get_theme_color("font_color", "Button") #get the color defined for button fonts
+ # Get the font color defined for the current Control's class, if it exists.
+ modulate = get_theme_color("font_color")
+ # Get the font color defined for the Button class.
+ modulate = get_theme_color("font_color", "Button")
[/gdscript]
[csharp]
public override void _Ready()
{
- Modulate = GetThemeColor("font_color", "Button"); //get the color defined for button fonts
+ // Get the font color defined for the current Control's class, if it exists.
+ Modulate = GetThemeColor("font_color");
+ // Get the font color defined for the Button class.
+ Modulate = GetThemeColor("font_color", "Button");
}
[/csharp]
[/codeblocks]
</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="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="int" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code].
+ Returns a constant from the first matching [Theme] in the tree if that [Theme] has a constant item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</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="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="Font" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code].
+ Returns a [Font] from the first matching [Theme] in the tree if that [Theme] has a font item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="get_theme_font_size" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="int" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns a font size from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code].
+ Returns a font size from the first matching [Theme] in the tree if that [Theme] has a font size item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</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="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="Texture2D" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code].
+ Returns an icon from the first matching [Theme] in the tree if that [Theme] has an icon item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="get_theme_stylebox" qualifiers="const">
- <return type="StyleBox">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="StyleBox" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns a [StyleBox] from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code].
+ Returns a [StyleBox] from the first matching [Theme] in the tree if that [Theme] has a stylebox item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="get_tooltip" qualifiers="const">
- <return type="String">
- </return>
- <argument index="0" name="at_position" type="Vector2" default="Vector2( 0, 0 )">
- </argument>
+ <return type="String" />
+ <argument index="0" name="at_position" type="Vector2" default="Vector2(0, 0)" />
<description>
Returns the tooltip, which will appear when the cursor is resting over this control. See [member hint_tooltip].
</description>
</method>
<method name="grab_click_focus">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Creates an [InputEventMouseButton] that attempts to click the control. If the event is received, the control acquires focus.
[codeblocks]
@@ -564,236 +519,185 @@
</description>
</method>
<method name="grab_focus">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Steal the focus from another control and become the focused control (see [member focus_mode]).
</description>
</method>
<method name="has_focus" qualifiers="const">
- <return type="bool">
- </return>
+ <return type="bool" />
<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="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if [Color] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has a color item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_color_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if [Color] with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme [Color] with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_color_override].
</description>
</method>
<method name="has_theme_constant" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if constant with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has a constant item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_constant_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if constant with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme constant with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_constant_override].
</description>
</method>
<method name="has_theme_font" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if font with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_font_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if font with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme [Font] with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_font_override].
</description>
</method>
<method name="has_theme_font_size" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if font size with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font size item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_font_size_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if font size with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme font size with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_font_size_override].
</description>
</method>
<method name="has_theme_icon" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if icon with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has an icon item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_icon_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if icon with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme icon with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_icon_override].
</description>
</method>
<method name="has_theme_stylebox" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
- <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
+ <argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
- Returns [code]true[/code] if [StyleBox] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme].
+ Returns [code]true[/code] if there is a matching [Theme] in the tree that has a stylebox item with the specified [code]name[/code] and [code]theme_type[/code].
+ See [method get_theme_color] for details.
</description>
</method>
<method name="has_theme_stylebox_override" qualifiers="const">
- <return type="bool">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="bool" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Returns [code]true[/code] if [StyleBox] with given [code]name[/code] has a valid override in this [Control] node.
+ Returns [code]true[/code] if there is a local override for a theme [StyleBox] with the specified [code]name[/code] in this [Control] node.
+ See [method add_theme_stylebox_override].
</description>
</method>
<method name="is_layout_rtl" qualifiers="const">
- <return type="bool">
- </return>
+ <return type="bool" />
<description>
Returns [code]true[/code] if layout is right-to-left.
</description>
</method>
<method name="minimum_size_changed">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Invalidates the size cache in this node and in parent nodes up to top_level. Intended to be used with [method get_minimum_size] when the return value is changed. Setting [member rect_min_size] directly calls this method automatically.
</description>
</method>
<method name="release_focus">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Give up the focus. No other control will be able to receive keyboard input.
</description>
</method>
<method name="remove_theme_color_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for a [Color] with the given [code]name[/code].
+ Removes a local override for a theme [Color] with the specified [code]name[/code] previously added by [method add_theme_color_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_constant_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for a constant with the given [code]name[/code].
+ Removes a local override for a theme constant with the specified [code]name[/code] previously added by [method add_theme_constant_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_font_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for a [Font] with the given [code]name[/code].
+ Removes a local override for a theme [Font] with the specified [code]name[/code] previously added by [method add_theme_font_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_font_size_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for a font size with the given [code]name[/code].
+ Removes a local override for a theme font size with the specified [code]name[/code] previously added by [method add_theme_font_size_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_icon_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for an icon with the given [code]name[/code].
+ Removes a local override for a theme icon with the specified [code]name[/code] previously added by [method add_theme_icon_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_stylebox_override">
- <return type="void">
- </return>
- <argument index="0" name="name" type="StringName">
- </argument>
+ <return type="void" />
+ <argument index="0" name="name" type="StringName" />
<description>
- Removes a theme override for a [StyleBox] with the given [code]name[/code].
+ Removes a local override for a theme [StyleBox] with the specified [code]name[/code] previously added by [method add_theme_stylebox_override] or via the Inspector dock.
</description>
</method>
<method name="set_anchor">
- <return type="void">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
- <argument index="1" name="anchor" type="float">
- </argument>
- <argument index="2" name="keep_offset" type="bool" default="false">
- </argument>
- <argument index="3" name="push_opposite_anchor" type="bool" default="true">
- </argument>
+ <return type="void" />
+ <argument index="0" name="side" type="int" enum="Side" />
+ <argument index="1" name="anchor" type="float" />
+ <argument index="2" name="keep_offset" type="bool" default="false" />
+ <argument index="3" name="push_opposite_anchor" type="bool" default="true" />
<description>
Sets the anchor for the specified [enum Side] to [code]anchor[/code]. A setter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top].
If [code]keep_offset[/code] is [code]true[/code], offsets aren't updated after this operation.
@@ -801,62 +705,46 @@
</description>
</method>
<method name="set_anchor_and_offset">
- <return type="void">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
- <argument index="1" name="anchor" type="float">
- </argument>
- <argument index="2" name="offset" type="float">
- </argument>
- <argument index="3" name="push_opposite_anchor" type="bool" default="false">
- </argument>
+ <return type="void" />
+ <argument index="0" name="side" type="int" enum="Side" />
+ <argument index="1" name="anchor" type="float" />
+ <argument index="2" name="offset" type="float" />
+ <argument index="3" name="push_opposite_anchor" type="bool" default="false" />
<description>
Works the same as [method set_anchor], but instead of [code]keep_offset[/code] argument and automatic update of offset, it allows to set the offset yourself (see [method set_offset]).
</description>
</method>
<method name="set_anchors_and_offsets_preset">
- <return type="void">
- </return>
- <argument index="0" name="preset" type="int" enum="Control.LayoutPreset">
- </argument>
- <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0">
- </argument>
- <argument index="2" name="margin" type="int" default="0">
- </argument>
+ <return type="void" />
+ <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" />
+ <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0" />
+ <argument index="2" name="margin" type="int" default="0" />
<description>
Sets both anchor preset and offset preset. See [method set_anchors_preset] and [method set_offsets_preset].
</description>
</method>
<method name="set_anchors_preset">
- <return type="void">
- </return>
- <argument index="0" name="preset" type="int" enum="Control.LayoutPreset">
- </argument>
- <argument index="1" name="keep_offsets" type="bool" default="false">
- </argument>
- <description>
- Sets the anchors to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor.
+ <return type="void" />
+ <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" />
+ <argument index="1" name="keep_offsets" type="bool" default="false" />
+ <description>
+ Sets the anchors to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.
If [code]keep_offsets[/code] is [code]true[/code], control's position will also be updated.
</description>
</method>
<method name="set_begin">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
+ <return type="void" />
+ <argument index="0" name="position" type="Vector2" />
<description>
Sets [member offset_left] and [member offset_top] at the same time. Equivalent of changing [member rect_position].
</description>
</method>
<method name="set_drag_forwarding">
- <return type="void">
- </return>
- <argument index="0" name="target" type="Control">
- </argument>
+ <return type="void" />
+ <argument index="0" name="target" type="Control" />
<description>
Forwards the handling of this control's drag and drop to [code]target[/code] control.
- Forwarding can be implemented in the target control similar to the methods [method get_drag_data], [method can_drop_data], and [method drop_data] but with two differences:
+ Forwarding can be implemented in the target control similar to the methods [method _get_drag_data], [method _can_drop_data], and [method _drop_data] but with two differences:
1. The function name must be suffixed with [b]_fw[/b]
2. The function must take an extra argument that is the control doing the forwarding
[codeblocks]
@@ -871,13 +759,13 @@
# TargetControl.gd
extends Control
- func can_drop_data_fw(position, data, from_control):
+ func _can_drop_data_fw(position, data, from_control):
return true
- func drop_data_fw(position, data, from_control):
+ func _drop_data_fw(position, data, from_control):
my_handle_data(data) # Your handler method.
- func get_drag_data_fw(position, from_control):
+ func _get_drag_data_fw(position, from_control):
set_drag_preview(my_preview)
return my_data()
[/gdscript]
@@ -917,17 +805,15 @@
</description>
</method>
<method name="set_drag_preview">
- <return type="void">
- </return>
- <argument index="0" name="control" type="Control">
- </argument>
+ <return type="void" />
+ <argument index="0" name="control" type="Control" />
<description>
- Shows the given control at the mouse pointer. A good time to call this method is in [method get_drag_data]. The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended.
+ Shows the given control at the mouse pointer. A good time to call this method is in [method _get_drag_data]. The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended.
[codeblocks]
[gdscript]
export (Color, RGBA) var color = Color(1, 0, 0, 1)
- func get_drag_data(position):
+ func _get_drag_data(position):
# Use a control that is not in the tree
var cpb = ColorPickerButton.new()
cpb.color = color
@@ -953,92 +839,69 @@
</description>
</method>
<method name="set_end">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
+ <return type="void" />
+ <argument index="0" name="position" type="Vector2" />
<description>
Sets [member offset_right] and [member offset_bottom] at the same time.
</description>
</method>
<method name="set_focus_neighbor">
- <return type="void">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
- <argument index="1" name="neighbor" type="NodePath">
- </argument>
+ <return type="void" />
+ <argument index="0" name="side" type="int" enum="Side" />
+ <argument index="1" name="neighbor" type="NodePath" />
<description>
Sets the anchor for the specified [enum Side] to the [Control] at [code]neighbor[/code] node path. A setter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top].
</description>
</method>
<method name="set_global_position">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <argument index="1" name="keep_offsets" type="bool" default="false">
- </argument>
+ <return type="void" />
+ <argument index="0" name="position" type="Vector2" />
+ <argument index="1" name="keep_offsets" type="bool" default="false" />
<description>
Sets the [member rect_global_position] to given [code]position[/code].
If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets.
</description>
</method>
<method name="set_offset">
- <return type="void">
- </return>
- <argument index="0" name="side" type="int" enum="Side">
- </argument>
- <argument index="1" name="offset" type="float">
- </argument>
+ <return type="void" />
+ <argument index="0" name="side" type="int" enum="Side" />
+ <argument index="1" name="offset" type="float" />
<description>
Sets the offset for the specified [enum Side] to [code]offset[/code]. A setter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top].
</description>
</method>
<method name="set_offsets_preset">
- <return type="void">
- </return>
- <argument index="0" name="preset" type="int" enum="Control.LayoutPreset">
- </argument>
- <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0">
- </argument>
- <argument index="2" name="margin" type="int" default="0">
- </argument>
- <description>
- Sets the offsets to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor.
+ <return type="void" />
+ <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" />
+ <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0" />
+ <argument index="2" name="margin" type="int" default="0" />
+ <description>
+ Sets the offsets to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.
Use parameter [code]resize_mode[/code] with constants from [enum Control.LayoutPresetMode] to better determine the resulting size of the [Control]. Constant size will be ignored if used with presets that change size, e.g. [code]PRESET_LEFT_WIDE[/code].
Use parameter [code]margin[/code] to determine the gap between the [Control] and the edges.
</description>
</method>
<method name="set_position">
- <return type="void">
- </return>
- <argument index="0" name="position" type="Vector2">
- </argument>
- <argument index="1" name="keep_offsets" type="bool" default="false">
- </argument>
+ <return type="void" />
+ <argument index="0" name="position" type="Vector2" />
+ <argument index="1" name="keep_offsets" type="bool" default="false" />
<description>
Sets the [member rect_position] to given [code]position[/code].
If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets.
</description>
</method>
<method name="set_size">
- <return type="void">
- </return>
- <argument index="0" name="size" type="Vector2">
- </argument>
- <argument index="1" name="keep_offsets" type="bool" default="false">
- </argument>
+ <return type="void" />
+ <argument index="0" name="size" type="Vector2" />
+ <argument index="1" name="keep_offsets" type="bool" default="false" />
<description>
Sets the size (see [member rect_size]).
If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets.
</description>
</method>
<method name="warp_mouse">
- <return type="void">
- </return>
- <argument index="0" name="to_position" type="Vector2">
- </argument>
+ <return type="void" />
+ <argument index="0" name="to_position" type="Vector2" />
<description>
Moves the mouse cursor to [code]to_position[/code], relative to [member rect_position] of this [Control].
</description>
@@ -1055,7 +918,11 @@
Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience.
</member>
<member name="anchor_top" type="float" setter="_set_anchor" getter="get_anchor" default="0.0">
- Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience.
+ Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience.
+ </member>
+ <member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" default="true">
+ Toggles if any text should automatically change to its translated version depending on the current locale. Note that this will not affect any internal nodes (e.g. the popup of a [MenuButton]).
+ Also decides if the node's strings should be parsed for POT generation.
</member>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" enum="Control.FocusMode" default="0">
The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals.
@@ -1067,7 +934,7 @@
Tells Godot which node it should give keyboard focus to if the user presses the left arrow on the keyboard or left on a gamepad by default. You can change the key by editing the [code]ui_left[/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 left of this one.
</member>
<member name="focus_neighbor_right" type="NodePath" setter="set_focus_neighbor" getter="get_focus_neighbor" default="NodePath(&quot;&quot;)">
- Tells Godot which node it should give keyboard focus to if the user presses the right arrow on the keyboard or right on a gamepad by default. You can change the key by editing the [code]ui_right[/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.
+ Tells Godot which node it should give keyboard focus to if the user presses the right arrow on the keyboard or right on a gamepad by default. You can change the key by editing the [code]ui_right[/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_neighbor_top" type="NodePath" setter="set_focus_neighbor" getter="get_focus_neighbor" default="NodePath(&quot;&quot;)">
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.
@@ -1135,32 +1002,29 @@
Offsets are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Offsets update automatically when you move or resize the node.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" default="false">
- 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.
+ 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 and won't receive input.
</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).
</member>
- <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2( 0, 0 )">
+ <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2(0, 0)">
The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.
</member>
- <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2( 0, 0 )">
+ <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2(0, 0)">
By default, the node's pivot is its top-left corner. When you change its [member rect_scale], it will scale around this pivot. Set this property to [member rect_size] / 2 to center the pivot in the node's rectangle.
</member>
- <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2( 0, 0 )">
+ <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2(0, 0)">
The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset].
</member>
<member name="rect_rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
The node's rotation around its pivot, in radians. See [member rect_pivot_offset] to change the pivot's position.
</member>
- <member name="rect_rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0">
- The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position.
- </member>
- <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )">
+ <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. The Control's [member hint_tooltip] will also scale according to this value.
[b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=https://docs.godotengine.org/en/latest/tutorials/viewports/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually.
- [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property.
+ [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instantiated. To set the Control's scale when it's instantiated, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property.
</member>
- <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2( 0, 0 )">
+ <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2(0, 0)">
The size of the node's bounding rectangle, in pixels. [Container] nodes update this property automatically.
</member>
<member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" default="1">
@@ -1175,8 +1039,9 @@
<member name="theme" type="Theme" setter="set_theme" getter="get_theme">
The [Theme] resource this node and all its [Control] children use. If a child node has its own [Theme] resource set, theme items are merged with child's definitions having higher priority.
</member>
- <member name="theme_custom_type" type="StringName" setter="set_theme_custom_type" getter="get_theme_custom_type" default="@&quot;&quot;">
- The type name used by this [Control] to look up its own theme items. By default, the class name of the node is used (e.g. [code]Button[/code] for the [Button] control), as well as the class names of all parent classes (in order of inheritance). Setting this property gives the highest priority to the type of the specified name, then falls back on the class names.
+ <member name="theme_type_variation" type="StringName" setter="set_theme_type_variation" getter="get_theme_type_variation" default="&amp;&quot;&quot;">
+ The name of a theme type variation used by this [Control] to look up its own theme items. When empty, the class name of the node is used (e.g. [code]Button[/code] for the [Button] control), as well as the class names of all parent classes (in order of inheritance).
+ When set, this property gives the highest priority to the type of the specified name. This type can in turn extend another type, forming a dependency chain. See [method Theme.set_type_variation]. If the theme item cannot be found using this type or its base types, lookup falls back on the class names.
[b]Note:[/b] To look up [Control]'s own items use various [code]get_theme_*[/code] methods without specifying [code]theme_type[/code].
[b]Note:[/b] Theme items are looked for in the tree order, from branch to root, where each [Control] node is checked for its [member theme] property. The earliest match against any type/class name is returned. The project-level Theme and the default Theme are checked last.
</member>
@@ -1193,8 +1058,7 @@
</description>
</signal>
<signal name="gui_input">
- <argument index="0" name="event" type="InputEvent">
- </argument>
+ <argument index="0" name="event" type="InputEvent" />
<description>
Emitted when the node receives an [InputEvent].
</description>
@@ -1207,11 +1071,13 @@
<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.
+ [b]Note:[/b] [signal mouse_entered] will not be emitted if the mouse enters a child [Control] node before entering the parent's [code]Rect[/code] area, at least until the mouse is moved to reach the parent's [code]Rect[/code] area.
</description>
</signal>
<signal name="mouse_exited">
<description>
Emitted when the mouse leaves the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it.
+ [b]Note:[/b] [signal mouse_exited] will be emitted if the mouse enters a child [Control] node, even if the mouse cursor is still inside the parent's [code]Rect[/code] area.
</description>
</signal>
<signal name="resized">