Virtual method to be implemented by the user. Returns whether _guiInput should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this Control. Similar to rectClipContent, but doesn't affect visibility. If not overridden, defaults to false.
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to rectMinSize 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.
Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See acceptEvent.
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 hintTooltip 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.setStylebox for the type "TooltipPanel" (see hintTooltip 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 rectMinSize to some non-zero value. Example of usage with a custom-constructed node:
Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to Node._unhandledInput or Node._unhandledKeyInput.
Overrides the Color with given name in the theme resource the control uses. Note: Unlike other theme overrides, there is no way to undo a color override without manually assigning the previous color. Example of overriding a label's color and resetting it later:
Godot calls this method to test if data from a control's getDragData can be dropped at position. position is local to this control. This method should only be used to test the data. Process the data in dropData.
Godot calls this method to pass you the data from a control's getDragData result. Godot first calls canDropData to test if data is allowed to drop at position where position is local to this control.
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.
Forces drag and bypasses getDragData and setDragPreview by passing data and preview. Drag will start even if the mouse is neither over nor pressed on this control. The methods canDropData and dropData must be implemented on controls that want to receive drop data.
Returns the anchor identified by margin constant from margin enum. A getter method for anchorBottom, anchorLeft, anchorRight and anchorTop.
Returns marginLeft and marginTop. See also rectPosition.
Returns combined minimum size from rectMinSize and getMinimumSize.
Returns the mouse cursor shape the control displays on mouse hover. See cursorshape.
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 canDropData and dropData. position is local to this control. Drag may be forced with forceDrag. A preview that will follow the mouse that should represent the data can be set with setDragPreview. A good time to set the preview is in this method.
Returns marginRight and marginBottom.
Returns the focus neighbour identified by margin constant from margin enum. A getter method for focusNeighbourBottom, focusNeighbourLeft, focusNeighbourRight and focusNeighbourTop.
Returns the control that has the keyboard focus or null if none.
Returns the position and size of the control relative to the top-left corner of the screen. See rectPosition and rectSize.
Returns the anchor identified by margin constant from margin enum. A getter method for marginBottom, marginLeft, marginRight and marginTop.
Returns the minimum size for this control. See rectMinSize.
Returns the width/height occupied in the parent control.
Returns the parent control node.
Returns the position and size of the control relative to the top-left corner of the parent Control. See rectPosition and rectSize.
Returns the rotation (in radians).
Returns the tooltip, which will appear when the cursor is resting over this control. See hintTooltip.
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 focusMode).
Returns true if Color with given name has a valid override in this Control node.
Returns true if constant with given name has a valid override in this Control node.
Returns true if this is the current focused control. See focusMode.
Returns true if font with given name has a valid override in this Control node.
Returns true if icon with given name has a valid override in this Control node.
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 get_rect().has_point(point).
Invalidates the size cache in this node and in parent nodes up to toplevel. Intended to be used with getMinimumSize when the return value is changed. Setting rectMinSize directly calls this method automatically.
Give up the focus. No other control will be able to receive keyboard input.
Sets the anchor identified by margin constant from margin enum to value anchor. A setter method for anchorBottom, anchorLeft, anchorRight and anchorTop. If keep_margin is true, margins 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.
Sets both anchor preset and margin preset. See setAnchorsPreset and setMarginsPreset.
Sets the anchors to a preset from Control.layoutpreset enum. This is the code equivalent to using the Layout menu in the 2D editor. If keep_margins is true, control's position will also be updated.
Sets marginLeft and marginTop at the same time. Equivalent of changing rectPosition.
Forwards the handling of this control's drag and drop to target control. Forwarding can be implemented in the target control similar to the methods getDragData, canDropData, and dropData but with two differences: 1. The function name must be suffixed with _fw 2. The function must take an extra argument that is the control doing the forwarding
Shows the given control at the mouse pointer. A good time to call this method is in getDragData. 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 marginRight and marginBottom at the same time.
Sets the anchor identified by margin constant from margin enum to Control at neighbor node path. A setter method for focusNeighbourBottom, focusNeighbourLeft, focusNeighbourRight and focusNeighbourTop.
Sets the rectGlobalPosition to given position. If keep_margins is true, control's anchors will be updated instead of margins.
Sets the margin identified by margin constant from margin enum to given offset. A setter method for marginBottom, marginLeft, marginRight and marginTop.
Sets the margins to a preset from Control.layoutpreset enum. This is the code equivalent to using the Layout menu in the 2D editor. Use parameter resize_mode with constants from 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. PRESET_LEFT_WIDE. Use parameter margin to determine the gap between the Control and the edges.
Sets the rectPosition to given position. If keep_margins is true, control's anchors will be updated instead of margins.
Sets the rotation (in radians).
Sets the size (see rectSize). If keep_margins is true, control's anchors will be updated instead of margins.
Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus. If exclusive is true, other controls will not receive input and clicking outside this control will not close it.
Moves the mouse cursor to to_position, relative to rectPosition of this Control.
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom margin 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 margin 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 margin 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 margin updates when the node moves or changes size. You can use one of the anchor constants for convenience.
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.
Tells Godot which node it should give keyboard 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 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 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 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 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 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 bottom of this one.
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 ui_top 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 Tab on a keyboard by default. You can change the key by editing the 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 keyboard focus to if the user presses Shift+Tab on a keyboard by default. You can change the key by editing the 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.
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.
Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments, provided that the mouseFilter property is not constant MOUSE_FILTER_IGNORE. You can change the time required for the tooltip to appear with gui/timers/tooltip_delay_sec option in Project Settings. The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding _makeCustomTooltip. 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:
Enables whether input should propagate when you close the control as modal. If false, stops event handling at the viewport input event handling. The viewport first hides the modal and after marks the input as handled.
Distance between the node's bottom edge and its parent control, based on anchorBottom. Margins 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. Margins update automatically when you move or resize the node.
Distance between the node's left edge and its parent control, based on anchorLeft. Margins 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. Margins update automatically when you move or resize the node.
Distance between the node's right edge and its parent control, based on anchorRight. Margins 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. Margins update automatically when you move or resize the node.
Distance between the node's top edge and its parent control, based on anchorTop. Margins 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. Margins update automatically when you move or resize the node.
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 _guiInput and how these events should be handled. Also controls whether the control can receive the mouseEntered, and mouseExited signals. See the constants to learn what each does.
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.
The node's global position, relative to the world (usually to the top-left corner of the window).
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 node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by rectPivotOffset.
The node's rotation around its pivot, in degrees. See rectPivotOffset to change the pivot's position.
The node's scale, relative to its rectSize. Change this property to scale the node around its rectPivotOffset. The Control's hintTooltip will also scale according to this value. Note: 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/3.3/tutorials/viewports/multiple_resolutions.htmldocumentation/url instead of scaling Controls individually. 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 instanced. To set the Control's scale when it's instanced, wait for one frame using yield(get_tree(), "idle_frame") then set its rectScale property.
The size of the node's bounding rectangle, in pixels. Container nodes update this property automatically.
Tells the parent Container nodes how they should resize and place the node on the X axis. Use one of the sizeflags constants to change the flags. See the constants to learn what each does.
Tells the parent Container nodes how they should resize and place the node on the X axis. Use one 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 neighbours uses the constant 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 neighbour 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 one of the sizeflags constants to change the flags. See the constants to learn what each does.
Construct a new instance of Control. Note: use memnew!Control instead.
All user interface nodes inherit from Control. A control's anchors and margins adapt its position and size relative to its parent.
Base class for all UI-related nodes. Control features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from Control and Container nodes. User Interface nodes and input Godot sends input events to the scene's root node first, by calling Node._input. 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 MainLoop._inputEvent. Call acceptEvent so no other node receives the event. Once you accept an input, it becomes handled so Node._unhandledInput 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 grabFocus. Control nodes lose focus when another node grabs it, or if you hide the node in focus. Sets mouseFilter 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 add_*_override methods, like addFontOverride. You can override the theme with the inspector. Note: Theme items are not GodotObject properties. This means you can't access their values using GodotObject.get and GodotObject.set. Instead, use getColor, getConstant, getFont, getIcon, getStylebox, and the add_*_override methods provided by this class.