-
Notifications
You must be signed in to change notification settings - Fork 0
class_control
####Inherits: CanvasItem ####Category: Core
Control is the base node for all the GUI components.
- void _input_event ( InputEvent event ) virtual
- bool can_drop_data ( Vector2 pos, var data ) virtual
- void drop_data ( Vector2 pos, var data ) virtual
- Object get_drag_data ( Vector2 pos ) virtual
- Vector2 get_minimum_size ( ) virtual
- void accept_event ( )
- Vector2 get_minimum_size ( ) const
- Vector2 get_combined_minimum_size ( ) const
- bool is_window ( ) const
- Object get_window ( ) const
- void set_anchor ( int margin, int anchor_mode )
- int get_anchor ( int margin ) const
- void set_margin ( int margin, float offset )
- void set_anchor_and_margin ( int margin, int anchor_mode, float offset )
- void set_begin ( Vector2 pos )
- void set_end ( Vector2 pos )
- void set_pos ( Vector2 pos )
- void set_size ( Vector2 size )
- void set_custom_minimum_size ( Vector2 size )
- void set_global_pos ( Vector2 pos )
- float get_margin ( int margin ) const
- Vector2 get_begin ( ) const
- Vector2 get_end ( ) const
- Vector2 get_pos ( ) const
- Vector2 get_size ( ) const
- Vector2 get_custom_minimum_size ( ) const
- Vector2 get_parent_area_size ( ) const
- Vector2 get_global_pos ( ) const
- Rect2 get_rect ( ) const
- Rect2 get_global_rect ( ) const
- void set_area_as_parent_rect ( int margin=0 )
- void show_modal ( bool exclusive=false )
- void set_focus_mode ( int mode )
- bool has_focus ( ) const
- void grab_focus ( )
- void release_focus ( )
- Control get_focus_owner ( ) const
- void set_h_size_flags ( int flags )
- int get_h_size_flags ( ) const
- void set_stretch_ratio ( float ratio )
- float get_stretch_ratio ( ) const
- void set_v_size_flags ( int flags )
- int get_v_size_flags ( ) const
- void set_theme ( Theme theme )
- Theme get_theme ( ) const
- void add_icon_override ( String name, Texture texture )
- void add_style_override ( String name, StyleBox stylebox )
- void add_font_override ( String name, Font font )
- void add_color_override ( String name, Color color )
- void add_constant_override ( String name, int constant )
- Texture get_icon ( String name, String type="" ) const
- StyleBox get_stylebox ( String name, String type="" ) const
- Font get_font ( String name, String type="" ) const
- Color get_color ( String name, String type="" ) const
- int get_constant ( String name, String type="" ) const
- Control get_parent_control ( ) const
- void set_tooltip ( String tooltip )
- String get_tooltip ( Vector2 atpos=Vector2(0,0) ) const
- void set_default_cursor_shape ( int shape )
- int get_default_cursor_shape ( ) const
- int get_cursor_shape ( Vector2 pos=Vector2(0,0) ) const
- void set_focus_neighbour ( int margin, NodePath neighbour )
- NodePath get_focus_neighbour ( int margin ) const
- void set_ignore_mouse ( bool ignore )
- bool is_ignoring_mouse ( ) const
- void force_drag ( var data, Object preview )
- void set_stop_mouse ( bool stop )
- bool is_stopping_mouse ( ) const
- void grab_click_focus ( )
- void set_drag_preview ( Control control )
- void warp_mouse ( Vector2 to_pos )
- focus_enter ( )
- mouse_enter ( )
- resized ( )
- minimum_size_changed ( )
- size_flags_changed ( )
- focus_exit ( )
- input_event ( InputEvent ev )
- mouse_exit ( )
- ANCHOR_BEGIN = 0 - X is relative to MARGIN_LEFT, Y is relative to MARGIN_TOP,
- ANCHOR_END = 1 - X is relative to -MARGIN_RIGHT, Y is relative to -MARGIN_BOTTOM,
- ANCHOR_RATIO = 2 - X and Y are a ratio (0 to 1) relative to the parent size 0 is left/top, 1 is right/bottom.
- ANCHOR_CENTER = 3
- FOCUS_NONE = 0 - Control can't acquire focus.
- FOCUS_CLICK = 1 - Control can acquire focus only if clicked.
- FOCUS_ALL = 2 - Control can acquire focus if clicked, or by pressing TAB/Directionals in the keyboard from another Control.
- NOTIFICATION_RESIZED = 40 - Control changed size (get_size() reports the new size).
- NOTIFICATION_MOUSE_ENTER = 41 - Mouse pointer entered the area of the Control.
- NOTIFICATION_MOUSE_EXIT = 42 - Mouse pointer exited the area of the Control.
- NOTIFICATION_FOCUS_ENTER = 43 - Control gained focus.
- NOTIFICATION_FOCUS_EXIT = 44 - Control lost focus.
- NOTIFICATION_THEME_CHANGED = 45 - Theme changed. Redrawing is desired.
- NOTIFICATION_MODAL_CLOSE = 46 - Modal control was closed.
- CURSOR_ARROW = 0
- CURSOR_IBEAM = 1
- CURSOR_POINTING_HAND = 2
- CURSOR_CROSS = 3
- CURSOR_WAIT = 4
- CURSOR_BUSY = 5
- CURSOR_DRAG = 6
- CURSOR_CAN_DROP = 7
- CURSOR_FORBIDDEN = 8
- CURSOR_VSIZE = 9
- CURSOR_HSIZE = 10
- CURSOR_BDIAGSIZE = 11
- CURSOR_FDIAGSIZE = 12
- CURSOR_MOVE = 13
- CURSOR_VSPLIT = 14
- CURSOR_HSPLIT = 15
- CURSOR_HELP = 16
- SIZE_EXPAND = 1
- SIZE_FILL = 2
- SIZE_EXPAND_FILL = 3
Control is the base class Node for all the GUI components. Every GUI component inherits from it, directly or indirectly. In this way, sections of the scene tree made of contiguous control nodes, become user interfaces. Controls are relative to the parent position and size by using anchors and margins. This ensures that they can adapt easily in most situation to changing dialog and screen sizes. When more flexibility is desired, Container derived nodes can be used. Anchors work by defining which margin do they follow, and a value relative to it. Allowed anchoring modes are ANCHOR_BEGIN, where the margin is relative to the top or left margins of the parent (in pixels), ANCHOR_END for the right and bottom margins of the parent and ANCHOR_RATIO, which is a ratio from 0 to 1 in the parent range. Input device events (InputEvent) are first sent to the root controls via the Node._input, which distribute it through the tree, then delivers them to the adequate one (under cursor or keyboard focus based) by calling [Node.input_event]. There is no need to enable input processing on controls to receive such events. To ensure that no one else will receive the event (not even Node._unhandled_input), the control can accept it by calling accept_event. Only one control can hold the keyboard focus (receiving keyboard events), for that the control must define the focus mode with set_focus_mode. Focus is lost when another control gains it, or the current focus owner is hidden. It is sometimes desired for a control to ignore mouse/pointer events. This is often the case when placing other controls on top of a button, in such cases. Calling set_ignore_mouse enables this function. Finally, controls are skinned according to a Theme. Setting a Theme on a control will propagate all the skinning down the tree. Optionally, skinning can be overrided per each control by calling the add*_override functions, or from the editor.
- void _input_event ( InputEvent event ) virtual
Called when an input event reaches the control.
- Vector2 get_minimum_size ( ) virtual
Return the minimum size this Control can shrink to. A control will never be displayed or resized smaller than its minimum size.
- void accept_event ( )
Handles the event, no other control will receive it and it will not be sent to nodes waiting on Node._unhandled_input or Node._unhandled_key_input.
- Vector2 get_minimum_size ( ) const
Return the minimum size this Control can shrink to. A control will never be displayed or resized smaller than its minimum size.
- bool is_window ( ) const
Return wether this control is a window. Controls are considered windows when their parent Node is not a Control.
- Object get_window ( ) const
Return the window for this control, ascending the scene tree (see is_window).
Change the anchor (ANCHOR_BEGIN, ANCHOR_END, ANCHOR_RATIO) type for a margin (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM). Changing the anchor mode converts the current margin offset from the previos anchor mode to the new one, so margin offsets (set_margin) must be done after setting anchors, or at the same time (set_anchor_and_margin).
Return the anchor type (ANCHOR_BEGIN, ANCHOR_END, ANCHOR_RATIO) for a given margin (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM).
Set a margin offset. Margin can be one of (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM). Offset value being set depends on the anchor mode.
Change the anchor (ANCHOR_BEGIN, ANCHOR_END, ANCHOR_RATIO) type for a margin (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM), and also set its offset. This is a helper (see set_anchor and set_margin).
- void set_begin ( Vector2 pos )
Sets MARGIN_LEFT and MARGIN_TOP at the same time. This is a helper (see set_margin).
- void set_end ( Vector2 pos )
Sets MARGIN_RIGHT and MARGIN_BOTTOM at the same time. This is a helper (see set_margin).
- void set_pos ( Vector2 pos )
Move the Control to a new position, relative to the top-left corner of the parent Control, changing all margins if needed and without changing current anchor mode. This is a helper (see set_margin).
- void set_size ( Vector2 size )
Changes MARGIN_RIGHT and MARGIN_BOTTOM to fit a given size. This is a helper (see set_margin).
- void set_global_pos ( Vector2 pos )
Move the Control to a new position, relative to the top-left corner of the window Control, and without changing current anchor mode. (see set_margin).
Return a margin offset. Margin can be one of (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM). Offset value being returned depends on the anchor mode.
- Vector2 get_end ( ) const
Returns MARGIN_LEFT and MARGIN_TOP at the same time. This is a helper (see set_margin).
- Vector2 get_pos ( ) const
Returns the Control position, relative to the top-left corner of the parent Control and independly of the anchor mode.
- Vector2 get_size ( ) const
Returns the size of the Control, computed from all margins, however the size returned will never be smaller than the minimum size reported by get_minimum_size. This means that even if end position of the Control rectangle is smaller than the begin position, the Control will still display and interact correctly. (see description, get_minimum_size, set_margin, set_anchor).
- Vector2 get_global_pos ( ) const
Returns the Control position, relative to the top-left corner of the parent Control and independent of the anchor mode.
- Rect2 get_rect ( ) const
Return position and size of the Control, relative to the top-left corner of the parent Control. This is a helper (see get_pos,get_size).
- Rect2 get_global_rect ( ) const
Return position and size of the Control, relative to the top-left corner of the window Control. This is a helper (see get_global_pos,get_size).
- void set_area_as_parent_rect ( int margin=0 )
Change all margins and anchors, so this Control always takes up the same area as the parent Control. This is a helper (see set_anchor,set_margin).
- void show_modal ( bool exclusive=false )
Display a Control as modal. Control must be a subwindow (see set_as_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.
- void set_focus_mode ( int mode )
Set the focus access mode for the control (FOCUS_NONE, FOCUS_CLICK, FOCUS_ALL). Only one Control can be focused at the same time, and it will receive keyboard signals.
- bool has_focus ( ) const
Return wether the Control is the current focused control (see set_focus_mode).
- void grab_focus ( )
Steal the focus from another control and become the focused control (see set_focus_mode).
- void release_focus ( )
Give up the focus, no other control will be able to receive keyboard input.
- Control get_focus_owner ( ) const
Return which control is owning the keyboard focus, or null if no one.
- void set_h_size_flags ( int flags )
Hint for containers, set horizontal positioning flags.
- int get_h_size_flags ( ) const
Hint for containers, return horizontal positioning flags.
- void set_stretch_ratio ( float ratio )
Hint for containers, set the stretch ratio. This value is relative to other stretch ratio, so if this control has 2 and another has 1, this one will be twice as big.
- float get_stretch_ratio ( ) const
Hint for containers, return the stretch ratio. This value is relative to other stretch ratio, so if this control has 2 and another has 1, this one will be twice as big.
- void set_v_size_flags ( int flags )
Hint for containers, set vertical positioning flags.
- int get_v_size_flags ( ) const
Hint for containers, return vertical positioning flags.
- void set_theme ( Theme theme )
Override whole the Theme for this Control and all its children controls.
- Theme get_theme ( ) const
Return a Theme override, if one exists (see set_theme).
Override a single icon (Texture) in the theme of this Control. If texture is empty, override is cleared.
Override a single stylebox ([Stylebox]) in the theme of this Control. If stylebox is empty, override is cleared.
Override a single font (font) in the theme of this Control. If font is empty, override is cleared.
Override a single constant (integer) in the theme of this Control. If constant equals Theme.INVALID_CONSTANT, override is cleared.
- void set_tooltip ( String tooltip )
Set a tooltip, which will appear when the cursor is resting over this control.
Return the tooltip, which will appear when the cursor is resting over this control.
- void set_default_cursor_shape ( int shape )
Set the default cursor shape for this control. See enum CURSOR_* for the list of shapes.
- int get_default_cursor_shape ( ) const
Return the default cursor shape for this control. See enum CURSOR_* for the list of shapes.
Return the cursor shape at a certain position in the control.
Force a neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
Return the forced neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
- void set_ignore_mouse ( bool ignore )
Ignore mouse events on this control (even touchpad events send mouse events).
- bool is_ignoring_mouse ( ) const
Return if the control is ignoring mouse events (even touchpad events send mouse events).