|
11 | 11 | Godot propagates input events via viewports. Each [Viewport] is responsible for propagating [InputEvent]s to their child nodes. As the [member SceneTree.root] is a [Window], this already happens automatically for all UI elements in your game.
|
12 | 12 | Input events are propagated through the [SceneTree] from the root node to all child nodes by calling [method Node._input]. For UI elements specifically, it makes more sense to override the virtual method [method _gui_input], which filters out unrelated input events, such as by checking z-order, [member mouse_filter], focus, or if the event was inside of the control's bounding box.
|
13 | 13 | 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.
|
14 |
| - Only one [Control] node can be in focus. Only the node in focus will receive 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. |
| 14 | + Only one [Control] node can be in focus. Only the node in focus will receive 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. Focus will not be represented visually if gained via mouse/touch input, only appearing with keyboard/gamepad input (for accessibility), or via [method grab_focus]. |
15 | 15 | 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.
|
16 | 16 | [Theme] resources change the control's appearance. The [member theme] of a [Control] node affects all of its direct and indirect children (as long as a chain of controls is uninterrupted). To override some of the theme items, call one of the [code]add_theme_*_override[/code] methods, like [method add_theme_font_override]. You can also override theme items in the Inspector.
|
17 | 17 | [b]Note:[/b] Theme items are [i]not[/i] [Object] properties. This means you can't access their values using [method Object.get] and [method Object.set]. Instead, use the [code]get_theme_*[/code] and [code]add_theme_*_override[/code] methods provided by this class.
|
|
618 | 618 | </method>
|
619 | 619 | <method name="grab_focus">
|
620 | 620 | <return type="void" />
|
| 621 | + <param index="0" name="hide_focus" type="bool" default="false" /> |
621 | 622 | <description>
|
622 | 623 | Steal the focus from another control and become the focused control (see [member focus_mode]).
|
| 624 | + If [param hide_focus] is [code]true[/code], the control will not visually show its focused state. |
623 | 625 | [b]Note:[/b] Using this method together with [method Callable.call_deferred] makes it more reliable, especially when called inside [method Node._ready].
|
624 | 626 | </description>
|
625 | 627 | </method>
|
626 | 628 | <method name="has_focus" qualifiers="const">
|
627 | 629 | <return type="bool" />
|
| 630 | + <param index="0" name="ignore_hidden_focus" type="bool" default="false" /> |
628 | 631 | <description>
|
629 | 632 | Returns [code]true[/code] if this is the current focused control. See [member focus_mode].
|
| 633 | + If [param ignore_hidden_focus] is [code]true[/code], controls that have its focus hidden will always return [code]false[/code]. Hidden focus happens automatically when controls gain focus via mouse input, or manually with [method grab_focus] with [code]hide_focus[/code] set to [code]true[/code]. |
630 | 634 | </description>
|
631 | 635 | </method>
|
632 | 636 | <method name="has_theme_color" qualifiers="const">
|
|
0 commit comments