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 offsets relative to the anchor. The offsets update automatically when the node, any of its parents, or the screen size change.
For more information on Godot's UI system, anchors, offsets, 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.
User Interface nodes and input
Godot propagates input events via viewports. Each Viewport is responsible for propagating InputEvents to their child nodes. As the SceneTree.root is a Window, this already happens automatically for all UI elements in your game.
Input events are propagated through the SceneTree from the root node to all child nodes by calling Node._input. For UI elements specifically, it makes more sense to override the virtual method _gui_input, which filters out unrelated input events, such as by checking z-order, mouse_filter, focus, or if the event was inside of the control's bounding box.
Call accept_event so no other node receives the event. Once you accept an input, it becomes handled so Node._unhandled_input will not process it.
Only one Control node can be in focus. Only the node in focus will receive events. To get the focus, call grab_focus. Control nodes lose focus when another node grabs it, or if you hide the node in focus.
Sets mouse_filter to 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 add_theme_*_override
methods, like add_theme_font_override. You can override the theme with the Inspector.
Emitted when the node gains focus.
Emitted when the node loses focus.
Emitted when the node receives an InputEvent.
Emitted when the node's minimum size changes.
Emitted when the mouse cursor enters the control's (or any child control's) visible area, that is not occluded behind other Controls or Windows, provided its mouse_filter lets the event reach it and regardless if it's currently focused or not.
Note: CanvasItem.z_index doesn't affect, which Control receives the signal.
Emitted when the mouse cursor leaves the control's (and all child control's) visible area, that is not occluded behind other Controls or Windows, provided its mouse_filter lets the event reach it and regardless if it's currently focused or not.
Note: CanvasItem.z_index doesn't affect, which Control receives the signal.
Note: If you want to check whether the mouse truly left the area, ignoring any top nodes, you can use code like this:
Emitted when the control changes size.
Emitted when one of the size flags changes. See size_flags_horizontal and size_flags_vertical.
Emitted when the NOTIFICATION_THEME_CHANGED notification is sent.
FOCUS_NONE = 0
The node cannot grab focus. Use with focus_mode.
FOCUS_CLICK = 1
The node can only grab focus on mouse clicks. Use with focus_mode.
FOCUS_ALL = 2
The node can grab focus on mouse click, using the arrows and the Tab keys on the keyboard, or using the D-pad buttons on a gamepad. Use with focus_mode.
CURSOR_ARROW = 0
Show the system's arrow mouse cursor when the user hovers the node. Use with mouse_default_cursor_shape.
CURSOR_IBEAM = 1
Show the system's I-beam mouse cursor when the user hovers the node. The I-beam pointer has a shape similar to "I". It tells the user they can highlight or insert text.
CURSOR_POINTING_HAND = 2
Show the system's pointing hand mouse cursor when the user hovers the node.
CURSOR_CROSS = 3
Show the system's cross mouse cursor when the user hovers the node.
CURSOR_WAIT = 4
Show the system's wait mouse cursor when the user hovers the node. Often an hourglass.
CURSOR_BUSY = 5
Show the system's busy mouse cursor when the user hovers the node. Often an arrow with a small hourglass.
CURSOR_DRAG = 6
Show the system's drag mouse cursor, often a closed fist or a cross symbol, when the user hovers the node. It tells the user they're currently dragging an item, like a node in the Scene dock.
CURSOR_CAN_DROP = 7
Show the system's drop mouse cursor when the user hovers the node. It can be an open hand. It tells the user they can drop an item they're currently grabbing, like a node in the Scene dock.
CURSOR_FORBIDDEN = 8
Show the system's forbidden mouse cursor when the user hovers the node. Often a crossed circle.
CURSOR_VSIZE = 9
Show the system's vertical resize mouse cursor when the user hovers the node. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
CURSOR_HSIZE = 10
Show the system's horizontal resize mouse cursor when the user hovers the node. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
CURSOR_BDIAGSIZE = 11
Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
CURSOR_FDIAGSIZE = 12
Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of CURSOR_BDIAGSIZE. It tells the user they can resize the window or the panel both horizontally and vertically.
CURSOR_MOVE = 13
Show the system's move mouse cursor when the user hovers the node. It shows 2 double-headed arrows at a 90 degree angle. It tells the user they can move a UI element freely.
CURSOR_VSPLIT = 14
Show the system's vertical split mouse cursor when the user hovers the node. On Windows, it's the same as CURSOR_VSIZE.
CURSOR_HSPLIT = 15
Show the system's horizontal split mouse cursor when the user hovers the node. On Windows, it's the same as CURSOR_HSIZE.
CURSOR_HELP = 16
Show the system's help mouse cursor when the user hovers the node, a question mark.
PRESET_TOP_LEFT = 0
Snap all 4 anchors to the top-left of the parent control's bounds. Use with set_anchors_preset.
PRESET_TOP_RIGHT = 1
Snap all 4 anchors to the top-right of the parent control's bounds. Use with set_anchors_preset.
PRESET_BOTTOM_LEFT = 2
Snap all 4 anchors to the bottom-left of the parent control's bounds. Use with set_anchors_preset.
PRESET_BOTTOM_RIGHT = 3
Snap all 4 anchors to the bottom-right of the parent control's bounds. Use with set_anchors_preset.
PRESET_CENTER_LEFT = 4
Snap all 4 anchors to the center of the left edge of the parent control's bounds. Use with set_anchors_preset.
PRESET_CENTER_TOP = 5
Snap all 4 anchors to the center of the top edge of the parent control's bounds. Use with set_anchors_preset.
PRESET_CENTER_RIGHT = 6
Snap all 4 anchors to the center of the right edge of the parent control's bounds. Use with set_anchors_preset.
PRESET_CENTER_BOTTOM = 7
Snap all 4 anchors to the center of the bottom edge of the parent control's bounds. Use with set_anchors_preset.
PRESET_CENTER = 8
Snap all 4 anchors to the center of the parent control's bounds. Use with set_anchors_preset.
PRESET_LEFT_WIDE = 9
Snap all 4 anchors to the left edge of the parent control. The left offset becomes relative to the left edge and the top offset relative to the top left corner of the node's parent. Use with set_anchors_preset.
PRESET_TOP_WIDE = 10
Snap all 4 anchors to the top edge of the parent control. The left offset becomes relative to the top left corner, the top offset relative to the top edge, and the right offset relative to the top right corner of the node's parent. Use with set_anchors_preset.
PRESET_RIGHT_WIDE = 11
Snap all 4 anchors to the right edge of the parent control. The right offset becomes relative to the right edge and the top offset relative to the top right corner of the node's parent. Use with set_anchors_preset.
PRESET_BOTTOM_WIDE = 12
Snap all 4 anchors to the bottom edge of the parent control. The left offset becomes relative to the bottom left corner, the bottom offset relative to the bottom edge, and the right offset relative to the bottom right corner of the node's parent. Use with set_anchors_preset.
PRESET_VCENTER_WIDE = 13
Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with set_anchors_preset.
PRESET_HCENTER_WIDE = 14
Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with set_anchors_preset.
PRESET_FULL_RECT = 15
Snap all 4 anchors to the respective corners of the parent control. Set all 4 offsets to 0 after you applied this preset and the Control will fit its parent control. Use with set_anchors_preset.
PRESET_MODE_MINSIZE = 0
The control will be resized to its minimum size.
PRESET_MODE_KEEP_WIDTH = 1
The control's width will not change.
PRESET_MODE_KEEP_HEIGHT = 2
The control's height will not change.
PRESET_MODE_KEEP_SIZE = 3
The control's size will not change.
SIZE_SHRINK_BEGIN = 0
Tells the parent Container to align the node with its start, either the top or the left edge. It is mutually exclusive with SIZE_FILL and other shrink size flags, but can be used with SIZE_EXPAND in some containers. Use with size_flags_horizontal and size_flags_vertical.
SIZE_FILL = 1
Tells the parent Container to expand the bounds of this node to fill all the available space without pushing any other node. It is mutually exclusive with shrink size flags. Use with size_flags_horizontal and size_flags_vertical.
SIZE_EXPAND = 2
Tells the parent Container to let this node take all the available space on the axis you flag. If multiple neighboring nodes are set to expand, they'll share the space based on their stretch ratio. See size_flags_stretch_ratio. Use with size_flags_horizontal and size_flags_vertical.
SIZE_EXPAND_FILL = 3
Sets the node's size flags to both fill and expand. See SIZE_FILL and SIZE_EXPAND for more information.
SIZE_SHRINK_CENTER = 4
Tells the parent Container to center the node in the available space. It is mutually exclusive with SIZE_FILL and other shrink size flags, but can be used with SIZE_EXPAND in some containers. Use with size_flags_horizontal and size_flags_vertical.
SIZE_SHRINK_END = 8
Tells the parent Container to align the node with its end, either the bottom or the right edge. It is mutually exclusive with SIZE_FILL and other shrink size flags, but can be used with SIZE_EXPAND in some containers. Use with size_flags_horizontal and size_flags_vertical.
MOUSE_FILTER_STOP = 0
The control will receive mouse movement input events and mouse button input events if clicked on through _gui_input. And the control will receive the mouse_entered and mouse_exited signals. These events are automatically marked as handled, and they will not propagate further to other controls. This also results in blocking signals in other controls.
MOUSE_FILTER_PASS = 1
The control will receive mouse movement input events and mouse button input events if clicked on through _gui_input. And the control will receive the mouse_entered and mouse_exited signals. If this control does not handle the event, the parent control (if any) will be considered, and so on until there is no more parent control to potentially handle it. This also allows signals to fire in other controls. If no control handled it, the event will be passed to Node._shortcut_input for further processing.
MOUSE_FILTER_IGNORE = 2
The control will not receive mouse movement input events and mouse button input events if clicked on through _gui_input. The control will also not receive the mouse_entered nor mouse_exited signals. This will not block other controls from receiving these events or firing the signals. Ignored events will not be handled automatically.
GROW_DIRECTION_BEGIN = 0
The control will grow to the left or top to make up if its minimum size is changed to be greater than its current size on the respective axis.
GROW_DIRECTION_END = 1
The control will grow to the right or bottom to make up if its minimum size is changed to be greater than its current size on the respective axis.
GROW_DIRECTION_BOTH = 2
The control will grow in both directions equally to make up if its minimum size is changed to be greater than its current size.
ANCHOR_BEGIN = 0
Snaps one of the 4 anchor's sides to the origin of the node's Rect
, in the top left. Use it with one of the anchor_*
member variables, like anchor_left. To change all 4 anchors at once, use set_anchors_preset.
ANCHOR_END = 1
Snaps one of the 4 anchor's sides to the end of the node's Rect
, in the bottom right. Use it with one of the anchor_*
member variables, like anchor_left. To change all 4 anchors at once, use set_anchors_preset.
LAYOUT_DIRECTION_INHERITED = 0
Automatic layout direction, determined from the parent control layout direction.
LAYOUT_DIRECTION_LOCALE = 1
Automatic layout direction, determined from the current locale.
LAYOUT_DIRECTION_LTR = 2
Left-to-right layout direction.
LAYOUT_DIRECTION_RTL = 3
Right-to-left layout direction.
TEXT_DIRECTION_INHERITED = 3
Text writing direction is the same as layout direction.
TEXT_DIRECTION_AUTO = 0
Automatic text writing direction, determined from the current locale and text content.
TEXT_DIRECTION_LTR = 1
Left-to-right text writing direction.
TEXT_DIRECTION_RTL = 2
Right-to-left text writing direction.
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
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 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 Anchor constants for convenience.
Toggles if any text should automatically change to its translated version depending on the current locale.
Also decides if the node's strings should be parsed for POT generation.
Enables whether rendering of CanvasItem based children should be clipped to this control's rectangle. If true
, parts of a child which would be visibly outside of this control's rectangle will not be rendered and won't receive input.
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.
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, gamepad, and mouse signals.
Tells Godot which node it should give focus to if the user presses the down arrow on the keyboard or down on a gamepad by default. You can change the key by editing the ProjectSettings.input/ui_down 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 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 ProjectSettings.input/ui_left 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.
Tells Godot which node it should give 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 ProjectSettings.input/ui_right input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the right of this one.
Tells Godot which node it should give 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 ProjectSettings.input/ui_up input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the top of this one.
Tells Godot which node it should give focus to if the user presses Tab on a keyboard by default. You can change the key by editing the ProjectSettings.input/ui_focus_next input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
Tells Godot which node it should give focus to if the user presses Shift + Tab on a keyboard by default. You can change the key by editing the ProjectSettings.input/ui_focus_prev input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
The node's global position, relative to the world (usually to the CanvasLayer).
Controls the direction on the horizontal axis in which the control should grow if its horizontal minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
Controls the direction on the vertical axis in which the control should grow if its vertical minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
Controls layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew).
If true
, automatically converts code line numbers, list indices, SpinBox and ProgressBar values from the Western Arabic (0..9) to the numeral systems used in current locale.
Note: Numbers within the text are not automatically converted, it can be done manually, using TextServer.format_number.
The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors.
Note: On Linux, shapes may vary depending on the cursor theme of the system.
Controls whether the control will be able to receive mouse button input events through _gui_input and how these events should be handled. Also controls whether the control can receive the mouse_entered, and mouse_exited signals. See the constants to learn what each does.
When enabled, scroll wheel events processed by _gui_input will be passed to the parent control even if mouse_filter is set to MOUSE_FILTER_STOP. As it defaults to true, this allows nested scrollable containers to work out of the box.
You should disable it on the root of your UI if you do not want scroll events to go to the Node._unhandled_input processing.
Distance between the node's bottom edge and its parent control, based on anchor_bottom.
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.
Distance between the node's left edge and its parent control, based on anchor_left.
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.
Distance between the node's right edge and its parent control, based on anchor_right.
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.
Distance between the node's top edge and its parent control, based on anchor_top.
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.
By default, the node's pivot is its top-left corner. When you change its rotation or scale, it will rotate or scale around this pivot. Set this property to size / 2 to pivot around the Control's center.
The node's position, relative to its containing node. It corresponds to the rectangle's top-left corner. The property is not affected by pivot_offset.
The node's rotation around its pivot, in radians. See pivot_offset to change the pivot's position.
Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use rotation_degrees.
Helper property to access rotation in degrees instead of radians.
The node's scale, relative to its size. Change this property to scale the node around its pivot_offset. The Control's tooltip_text will also scale according to this value.
Note: This property is mainly intended to be used for animation purposes. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the documentation instead of scaling Controls individually.
Note: FontFile.oversampling does not take Control scale into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field (applies to the default project font only), or enabling Multichannel Signed Distance Field in the import options of a DynamicFont for custom fonts. On system fonts, SystemFont.multichannel_signed_distance_field can be enabled in the inspector.
Note: If the Control node is a child of a Container node, the scale will be reset to Vector2(1, 1)
when the scene is instantiated. To set the Control's scale when it's instantiated, wait for one frame using await get_tree().process_frame
then set its scale property.
The Node which must be a parent of the focused Control for the shortcut to be activated. If null
, the shortcut can be activated when any control is focused (a global shortcut). This allows shortcuts to be accepted only when the user has a certain area of the GUI focused.
The size of the node's bounding rectangle, in the node's coordinate system. Container nodes update this property automatically.
Tells the parent Container nodes how they should resize and place the node on the X axis. Use a combination of the SizeFlags constants to change the flags. See the constants to learn what each does.
If the node and at least one of its neighbors uses the SIZE_EXPAND size flag, the parent Container will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbor a ratio of 1, this node will take two thirds of the available space.
Tells the parent Container nodes how they should resize and place the node on the Y axis. Use a combination of the SizeFlags constants to change the flags. See the constants to learn what each does.
The Theme resource this node and all its Control and Window children use. If a child node has its own Theme resource set, theme items are merged with child's definitions having higher priority.
Note: Window styles will have no effect unless the window is embedded.
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. Button
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 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.
Note: To look up Control's own items use various get_theme_*
methods without specifying theme_type
.
Note: Theme items are looked for in the tree order, from branch to root, where each Control node is checked for its theme property. The earliest match against any type/class name is returned. The project-level Theme and the default Theme are checked last.
The default tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments, provided that the mouse_filter property is not MOUSE_FILTER_IGNORE. The time required for the tooltip to appear can be changed with the ProjectSettings.gui/timers/tooltip_delay_sec option. See also get_tooltip.
The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding _make_custom_tooltip. The default tooltip includes a PopupPanel and Label whose theme properties can be customized using Theme methods with the "TooltipPanel"
and "TooltipLabel"
respectively. For example:
Godot calls this method to test if data
from a control's _get_drag_data can be dropped at at_position
. at_position
is local to this control.
This method should only be used to test the data. Process the data in _drop_data.
Godot calls this method to pass you the data
from a control's _get_drag_data result. Godot first calls _can_drop_data to test if data
is allowed to drop at at_position
where at_position
is local to this control.
Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns null
if there is no data to drag. Controls that want to receive drop data should implement _can_drop_data and _drop_data. at_position
is local to this control. Drag may be forced with force_drag.
A preview that will follow the mouse that should represent the data can be set with set_drag_preview. A good time to set the preview is in this method.
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to custom_minimum_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 Vector2.ZERO.
Note: This method will not be called when the script is attached to a Control node that already overrides its minimum size (e.g. Label, Button, PanelContainer etc.). It can only be used with most basic GUI nodes, like Control, Container, Panel etc.
Virtual method to be implemented by the user. Returns the tooltip text for the position at_position
in control's local coordinates, which will typically appear when the cursor is resting over this control. See get_tooltip.
Note: If this method returns an empty String, no tooltip is displayed.
Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See accept_event.
Example usage for clicking a control:
The event won't trigger if:
* clicking outside the control (see _has_point);
* control has mouse_filter set to MOUSE_FILTER_IGNORE;
* control is obstructed by another Control on top of it, which doesn't have mouse_filter set to MOUSE_FILTER_IGNORE;
* control's parent has mouse_filter set to MOUSE_FILTER_STOP or has accepted the event;
* it happens outside the parent's rectangle and the parent has either clip_contents enabled.
Note: Event position is relative to the control origin.
Virtual method to be implemented by the user. Returns whether the given point
is inside this control.
If not overridden, default behavior is checking if the point is within control's Rect.
Note: If you want to check if a point is inside the control, you can use Rect2(Vector2.ZERO, size).has_point(point)
.
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 for_text
includes the contents of the tooltip_text 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 null
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 Theme.set_stylebox for the type "TooltipPanel"
(see tooltip_text for an example).
Note: The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its custom_minimum_size to some non-zero value.
Note: The node (and any relevant children) should be 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:
Example of usage with a custom scene instance:
User defined BiDi algorithm override function.
Returns an Array of Vector3i text ranges and text base directions, in the left-to-right order. Ranges should cover full source text
without overlaps. BiDi algorithm will be used on each range separately.
Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to Node._unhandled_input or Node._unhandled_key_input.
Note: This does not affect the methods in Input, only the way events are propagated.
Creates a local override for a theme Color with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_color_override.
See also get_theme_color.
Example of overriding a label's color and resetting it later:
Creates a local override for a theme constant with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_constant_override.
See also get_theme_constant.
Creates a local override for a theme Font with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_font_override.
See also get_theme_font.
Creates a local override for a theme font size with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_font_size_override.
See also get_theme_font_size.
Creates a local override for a theme icon with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_icon_override.
See also get_theme_icon.
Creates a local override for a theme StyleBox with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_stylebox_override.
See also get_theme_stylebox.
Example of modifying a property in a StyleBox by duplicating it:
Prevents *_theme_*_override
methods from emitting NOTIFICATION_THEME_CHANGED until end_bulk_theme_override is called.
Ends a bulk theme override update. See begin_bulk_theme_override.
Finds the next (below in the tree) Control that can receive the focus.
Finds the previous (above in the tree) Control that can receive the focus.
Finds the next Control that can receive the focus on the specified Side.
Note: This is different from get_focus_neighbor, which returns the path of a specified focus neighbor.
Forces drag and bypasses _get_drag_data and set_drag_preview by passing data
and preview
. Drag will start even if the mouse is neither over nor pressed on this control.
The methods _can_drop_data and _drop_data must be implemented on controls that want to receive drop data.
Returns the anchor for the specified Side. A getter method for anchor_bottom, anchor_left, anchor_right and anchor_top.
Returns offset_left and offset_top. See also position.
Returns combined minimum size from custom_minimum_size and get_minimum_size.
Returns the mouse cursor shape the control displays on mouse hover. See CursorShape.
Returns offset_right and offset_bottom.
Returns the focus neighbor for the specified Side. A getter method for focus_neighbor_bottom, focus_neighbor_left, focus_neighbor_right and focus_neighbor_top.
Note: To find the next Control on the specific Side, even if a neighbor is not assigned, use find_valid_focus_neighbor.
Returns the position and size of the control relative to the containing canvas. See global_position and size.
Note: If the node itself or any parent CanvasItem between the node and the canvas have a non default rotation or skew, the resulting size is likely not meaningful.
Note: Setting Viewport.gui_snap_controls_to_pixels to true
can lead to rounding inaccuracies between the displayed control and the returned Rect2.
Returns the minimum size for this control. See custom_minimum_size.
Returns the offset for the specified Side. A getter method for offset_bottom, offset_left, offset_right and offset_top.
Returns the width/height occupied in the parent control.
Returns the parent control node.
Returns the position and size of the control in the coordinate system of the containing node. See position, scale and size.
Note: If rotation is not the default rotation, the resulting size is not meaningful.
Note: Setting Viewport.gui_snap_controls_to_pixels to true
can lead to rounding inaccuracies between the displayed control and the returned Rect2.
Returns the position of this Control in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
Equals to global_position if the window is embedded (see Viewport.gui_embed_subwindows).
Example usage for showing a popup:
Returns a Color from the first matching Theme in the tree if that Theme has a color item with the specified name
and theme_type
. If theme_type
is omitted the class name of the current control is used as the type, or 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 add_theme_color_override), then its assigned theme. After the current control, each parent control and its assigned theme are considered; controls without a theme assigned are skipped. If no matching Theme is found in the tree, the custom project Theme (see ProjectSettings.gui/theme/custom) and the default Theme are used (see ThemeDB).
Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified name
and theme_type
.
See get_theme_color for details.
Returns the default base scale value from the first matching Theme in the tree if that Theme has a valid Theme.default_base_scale value.
See get_theme_color for details.
Returns the default font from the first matching Theme in the tree if that Theme has a valid Theme.default_font value.
See get_theme_color for details.
Returns the default font size value from the first matching Theme in the tree if that Theme has a valid Theme.default_font_size value.
See get_theme_color for details.
Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified name
and theme_type
.
See get_theme_color for details.
Returns a font size from the first matching Theme in the tree if that Theme has a font size item with the specified name
and theme_type
.
See get_theme_color for details.
Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified name
and theme_type
.
See get_theme_color for details.
Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified name
and theme_type
.
See get_theme_color for details.
Returns the tooltip text for the position at_position
in control's local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns tooltip_text.
This method can be overridden to customize its behavior. See _get_tooltip.
Note: If this method returns an empty String, no tooltip is displayed.
Creates an InputEventMouseButton that attempts to click the control. If the event is received, the control acquires focus.
Steal the focus from another control and become the focused control (see focus_mode).
Note: Using this method together with Callable.call_deferred makes it more reliable, especially when called inside Node._ready.
Returns true
if this is the current focused control. See focus_mode.
Returns true
if there is a matching Theme in the tree that has a color item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme Color with the specified name
in this Control node.
Returns true
if there is a matching Theme in the tree that has a constant item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme constant with the specified name
in this Control node.
Returns true
if there is a matching Theme in the tree that has a font item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme Font with the specified name
in this Control node.
Returns true
if there is a matching Theme in the tree that has a font size item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme font size with the specified name
in this Control node.
Returns true
if there is a matching Theme in the tree that has an icon item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme icon with the specified name
in this Control node.
Returns true
if there is a matching Theme in the tree that has a stylebox item with the specified name
and theme_type
.
See get_theme_color for details.
Returns true
if there is a local override for a theme StyleBox with the specified name
in this Control node.
Returns true
if a drag operation is successful. Alternative to Viewport.gui_is_drag_successful.
Best used with Node.NOTIFICATION_DRAG_END.
Returns true
if layout is right-to-left.
Give up the focus. No other control will be able to receive input.
Removes a local override for a theme Color with the specified name
previously added by add_theme_color_override or via the Inspector dock.
Removes a local override for a theme constant with the specified name
previously added by add_theme_constant_override or via the Inspector dock.
Removes a local override for a theme Font with the specified name
previously added by add_theme_font_override or via the Inspector dock.
Removes a local override for a theme font size with the specified name
previously added by add_theme_font_size_override or via the Inspector dock.
Removes a local override for a theme icon with the specified name
previously added by add_theme_icon_override or via the Inspector dock.
Removes a local override for a theme StyleBox with the specified name
previously added by add_theme_stylebox_override or via the Inspector dock.
Resets the size to get_combined_minimum_size. This is equivalent to calling set_size(Vector2())
(or any size below the minimum).
Sets the anchor for the specified Side to anchor
. A setter method for anchor_bottom, anchor_left, anchor_right and anchor_top.
If keep_offset
is true
, offsets aren't updated after this operation.
If push_opposite_anchor
is true
and the opposite anchor overlaps this anchor, the opposite one will have its value overridden. For example, when setting left anchor to 1 and the right anchor has value of 0.5, the right anchor will also get value of 1. If push_opposite_anchor
was false
, the left anchor would get value 0.5.
Works the same as set_anchor, but instead of keep_offset
argument and automatic update of offset, it allows to set the offset yourself (see set_offset).
Sets both anchor preset and offset preset. See set_anchors_preset and set_offsets_preset.
Sets the anchors to a preset
from LayoutPreset enum. This is the code equivalent to using the Layout menu in the 2D editor.
If keep_offsets
is true
, control's position will also be updated.
Sets offset_left and offset_top at the same time. Equivalent of changing position.
Forwards the handling of this control's _get_drag_data, _can_drop_data and _drop_data virtual functions to delegate callables.
For each argument, if not empty, the delegate callable is used, otherwise the local (virtual) function is used.
The function format for each callable should be exactly the same as the virtual functions described above.
Shows the given control at the mouse pointer. A good time to call this method is in _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.
Sets offset_right and offset_bottom at the same time.
Sets the focus neighbor for the specified Side to the Control at neighbor
node path. A setter method for focus_neighbor_bottom, focus_neighbor_left, focus_neighbor_right and focus_neighbor_top.
Sets the global_position to given position
.
If keep_offsets
is true
, control's anchors will be updated instead of offsets.
Sets the offset for the specified Side to offset
. A setter method for offset_bottom, offset_left, offset_right and offset_top.
Sets the offsets to a preset
from LayoutPreset enum. This is the code equivalent to using the Layout menu in the 2D editor.
Use parameter resize_mode
with constants from LayoutPresetMode to better determine the resulting size of the Control. Constant size will be ignored if used with presets that change size, e.g. PRESET_LEFT_WIDE.
Use parameter margin
to determine the gap between the Control and the edges.
Sets the position to given position
.
If keep_offsets
is true
, control's anchors will be updated instead of offsets.
Sets the size (see size).
If keep_offsets
is true
, control's anchors will be updated instead of offsets.
Invalidates the size cache in this node and in parent nodes up to top level. Intended to be used with get_minimum_size when the return value is changed. Setting custom_minimum_size directly calls this method automatically.
Moves the mouse cursor to position
, relative to position of this Control.
Note: warp_mouse is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.