Parcourir la source

Merge pull request #59855 from KoBeWi/focus_thief

Rémi Verschelde il y a 3 ans
Parent
commit
62de7cec79
2 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 4 0
      doc/classes/Callable.xml
  2. 1 0
      doc/classes/Control.xml

+ 4 - 0
doc/classes/Callable.xml

@@ -75,6 +75,10 @@
 			<return type="void" />
 			<description>
 				Calls the method represented by this [Callable] in deferred mode, i.e. during the idle frame. Arguments can be passed and should match the method's signature.
+				[codeblock]
+				func _ready():
+				    grab_focus.call_deferred()
+				[/codeblock]
 			</description>
 		</method>
 		<method name="get_method" qualifiers="const">

+ 1 - 0
doc/classes/Control.xml

@@ -553,6 +553,7 @@
 			<return type="void" />
 			<description>
 				Steal the focus from another control and become the focused control (see [member focus_mode]).
+				[b]Note[/b]: Using this method together with [method Callable.call_deferred] makes it more reliable, especially when called inside [method Node._ready].
 			</description>
 		</method>
 		<method name="has_focus" qualifiers="const">