diff options
Diffstat (limited to 'doc/classes/Control.xml')
-rw-r--r-- | doc/classes/Control.xml | 136 |
1 files changed, 84 insertions, 52 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 214f78afab..4b6a9cca8a 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Control" inherits="CanvasItem" category="Core" version="3.0-beta"> +<class name="Control" inherits="CanvasItem" category="Core" version="3.1"> <brief_description> All User Interface nodes inherit from Control. Features anchors and margins to adapt its position and size to its parent. </brief_description> @@ -8,11 +8,13 @@ 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 [code]Control[/code] and [Container] nodes. [b]User Interface nodes and input[/b] Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [method MainLoop._input_event]. Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. - Only one [code]Control[/code] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the foucs, call [method set_focus_mode]. [code]Control[/code] nodes lose focus when another node grabs it, or if you hide the node in focus. - Call [method set_ignore_mouse] to tell a [code]Control[/code] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button. + Only one [code]Control[/code] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call [method grab_focus]. [code]Control[/code] nodes lose focus when another node grabs it, or if you hide the node in focus. + Set [member mouse_filter] to MOUSE_FILTER_IGNORE to tell a [code]Control[/code] 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 [code]Control[/code] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_*_override[/code] methods, like [method add_font_override]. You can override the theme with the inspector. </description> <tutorials> + http://docs.godotengine.org/en/3.0/tutorials/gui/index.html + http://docs.godotengine.org/en/3.0/tutorials/2d/custom_drawing_in_2d.html </tutorials> <demos> </demos> @@ -96,7 +98,7 @@ Overrides the [code]name[/code] shader in the [theme] resource the node uses. If [code]shader[/code] is empty, Godot clears the override. </description> </method> - <method name="add_style_override"> + <method name="add_stylebox_override"> <return type="void"> </return> <argument index="0" name="name" type="String"> @@ -115,6 +117,16 @@ <argument index="1" name="data" type="Variant"> </argument> <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]. + [codeblock] + extends Control + + 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') + [/codeblock] </description> </method> <method name="drop_data" qualifiers="virtual"> @@ -125,6 +137,16 @@ <argument index="1" name="data" type="Variant"> </argument> <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. + [codeblock] + extends ColorRect + + func can_drop_data(position, data): + return typeof(data) == TYPE_DICTIONARY and data.has('color') + + func drop_data(position, data): + color = data['color'] + [/codeblock] </description> </method> <method name="force_drag"> @@ -135,6 +157,8 @@ <argument index="1" name="preview" type="Control"> </argument> <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. </description> </method> <method name="get_begin" qualifiers="const"> @@ -178,19 +202,22 @@ Returns the mouse cursor shape the control displays on mouse hover, one of the [code]CURSOR_*[/code] constants. </description> </method> - <method name="get_default_cursor_shape" qualifiers="const"> - <return type="int" enum="Control.CursorShape"> - </return> - <description> - Returns the default cursor shape for this control. See enum [code]CURSOR_*[/code] for the list of shapes. - </description> - </method> <method name="get_drag_data" qualifiers="virtual"> <return type="Object"> </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. Return null 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. + [codeblock] + extends Control + + func get_drag_data(position): + var mydata = make_data() + set_drag_preview(make_preview(mydata)) + return mydata + [/codeblock] </description> </method> <method name="get_end" qualifiers="const"> @@ -200,13 +227,6 @@ Returns MARGIN_LEFT and MARGIN_TOP at the same time. This is a helper (see [method set_margin]). </description> </method> - <method name="get_focus_mode" qualifiers="const"> - <return type="int" enum="Control.FocusMode"> - </return> - <description> - Returns the focus access mode for the control (FOCUS_NONE, FOCUS_CLICK, FOCUS_ALL) (see [method set_focus_mode]). - </description> - </method> <method name="get_focus_owner" qualifiers="const"> <return type="Control"> </return> @@ -224,13 +244,6 @@ <description> </description> </method> - <method name="get_global_position" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the Control position, relative to the top-left corner of the parent Control and independent of the anchor mode. - </description> - </method> <method name="get_global_rect" qualifiers="const"> <return type="Rect2"> </return> @@ -400,6 +413,14 @@ <description> </description> </method> + <method name="has_shader_override" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <description> + </description> + </method> <method name="has_stylebox" qualifiers="const"> <return type="bool"> </return> @@ -490,21 +511,34 @@ Sets MARGIN_LEFT and MARGIN_TOP at the same time. This is a helper (see [method set_margin]). </description> </method> - <method name="set_default_cursor_shape"> - <return type="void"> - </return> - <argument index="0" name="shape" type="int" enum="Control.CursorShape"> - </argument> - <description> - Sets the default cursor shape for this control. See [code]CURSOR_*[/code] for the list of available cursor shapes. Useful for Godot plugins and applications or games that use the system's mouse cursors. - </description> - </method> <method name="set_drag_forwarding"> <return type="void"> </return> <argument index="0" name="target" type="Control"> </argument> <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: + 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 + [codeblock] + # ThisControl.gd + extends Control + func _ready(): + set_drag_forwarding(target_control) + + # TargetControl.gd + extends Control + func can_drop_data_fw(position, data, from_control): + return true + + func drop_data_fw(position, data, from_control): + my_handle_data(data) + + func get_drag_data_fw(position, from_control): + set_drag_preview(my_preview) + return my_data() + [/codeblock] </description> </method> <method name="set_drag_preview"> @@ -513,6 +547,7 @@ <argument index="0" name="control" type="Control"> </argument> <description> + Shows the given control at the mouse pointer. A good time to call this method is in [method get_drag_data]. </description> </method> <method name="set_end"> @@ -524,24 +559,6 @@ Sets MARGIN_RIGHT and MARGIN_BOTTOM at the same time. This is a helper (see [method set_margin]). </description> </method> - <method name="set_focus_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="Control.FocusMode"> - </argument> - <description> - 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. - </description> - </method> - <method name="set_global_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <description> - Move the Control to a new position, relative to the top-left corner of the [i]window[/i] Control, and without changing current anchor mode. (see [method set_margin]). - </description> - </method> <method name="set_margins_preset"> <return type="void"> </return> @@ -594,6 +611,9 @@ <member name="anchor_top" type="float" setter="_set_anchor" getter="get_anchor"> Anchors the top edge of the node to the origin, the center or the end of its parent container. It changes how the top margin updates when the node moves or changes size. Use one of the [code]ANCHOR_*[/code] constants. Default value: [code]ANCHOR_BEGIN[/code]. </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" enum="Control.FocusMode"> + 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. + </member> <member name="focus_neighbour_bottom" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour"> Tells Godot which node it should give keyboard focus to if the user presses Tab, the down arrow on the keyboard, or down on a gamepad. The node must be a [code]Control[/code]. If this property is not set, Godot will give focus to the closest [code]Control[/code] to the bottom of this one. If the user presses Tab, Godot will give focus to the closest node to the right first, then to the bottom. If the user presses Shift+Tab, Godot will look to the left of the node, then above it. @@ -631,11 +651,17 @@ <member name="margin_top" type="float" setter="set_margin" getter="get_margin"> Distance between the node's top edge and its parent container, based on [member anchor_top]. </member> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" enum="Control.CursorShape"> + The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors. + </member> <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" enum="Control.MouseFilter"> Controls whether the control will be able to receive mouse button input events through [method _gui_input] and how these events should be handled. Use one of the [code]MOUSE_FILTER_*[/code] constants. See the constants to learn what each does. </member> <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents"> </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"> 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> @@ -747,6 +773,10 @@ <constant name="NOTIFICATION_MODAL_CLOSE" value="46"> Sent when an open modal dialog closes. See [member show_modal]. </constant> + <constant name="NOTIFICATION_SCROLL_BEGIN" value="47"> + </constant> + <constant name="NOTIFICATION_SCROLL_END" value="48"> + </constant> <constant name="CURSOR_ARROW" value="0" enum="CursorShape"> Show the system's arrow mouse cursor when the user hovers the node. Use with [method set_default_cursor_shape]. </constant> @@ -882,6 +912,8 @@ </constant> <constant name="GROW_DIRECTION_END" value="1" enum="GrowDirection"> </constant> + <constant name="GROW_DIRECTION_BOTH" value="2" enum="GrowDirection"> + </constant> <constant name="ANCHOR_BEGIN" value="0" enum="Anchor"> Snaps one of the 4 anchor's sides to the origin of the node's [code]Rect[/code], in the top left. Use it with one of the [code]anchor_*[/code] member variables, like [member anchor_left]. To change all 4 anchors at once, use [method set_anchors_preset]. </constant> |