class_control.rst 163 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Control.xml.
  6. .. _class_Control:
  7. Control
  8. =======
  9. **Inherits:** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`BaseButton<class_BaseButton>`, :ref:`ColorRect<class_ColorRect>`, :ref:`Container<class_Container>`, :ref:`GraphEdit<class_GraphEdit>`, :ref:`ItemList<class_ItemList>`, :ref:`Label<class_Label>`, :ref:`LineEdit<class_LineEdit>`, :ref:`NinePatchRect<class_NinePatchRect>`, :ref:`Panel<class_Panel>`, :ref:`Popup<class_Popup>`, :ref:`Range<class_Range>`, :ref:`ReferenceRect<class_ReferenceRect>`, :ref:`RichTextLabel<class_RichTextLabel>`, :ref:`Separator<class_Separator>`, :ref:`Tabs<class_Tabs>`, :ref:`TextEdit<class_TextEdit>`, :ref:`TextureRect<class_TextureRect>`, :ref:`Tree<class_Tree>`, :ref:`VideoPlayer<class_VideoPlayer>`
  11. All user interface nodes inherit from Control. A control's anchors and margins adapt its position and size relative to its parent.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. 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.
  16. 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 :ref:`Container<class_Container>` nodes.
  17. \ **User Interface nodes and input**\
  18. Godot sends input events to the scene's root node first, by calling :ref:`Node._input<class_Node_method__input>`. :ref:`Node._input<class_Node_method__input>` forwards the event down the node tree to the nodes under the mouse cursor, or in focus. To do so, it calls :ref:`MainLoop._input_event<class_MainLoop_method__input_event>`. Call :ref:`accept_event<class_Control_method_accept_event>` so no other node receives the event. Once you accept an input, it becomes handled so :ref:`Node._unhandled_input<class_Node_method__unhandled_input>` will not process it.
  19. Only one **Control** node can be in focus. Only the node in focus will receive events. To get the focus, call :ref:`grab_focus<class_Control_method_grab_focus>`. **Control** nodes lose focus when another node grabs it, or if you hide the node in focus.
  20. Sets :ref:`mouse_filter<class_Control_property_mouse_filter>` to :ref:`MOUSE_FILTER_IGNORE<class_Control_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.
  21. \ :ref:`Theme<class_Theme>` resources change the Control's appearance. If you change the :ref:`Theme<class_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 :ref:`add_font_override<class_Control_method_add_font_override>`. You can override the theme with the inspector.
  22. \ **Note:** Theme items are *not* :ref:`Object<class_Object>` properties. This means you can't access their values using :ref:`Object.get<class_Object_method_get>` and :ref:`Object.set<class_Object_method_set>`. Instead, use :ref:`get_color<class_Control_method_get_color>`, :ref:`get_constant<class_Control_method_get_constant>`, :ref:`get_font<class_Control_method_get_font>`, :ref:`get_icon<class_Control_method_get_icon>`, :ref:`get_stylebox<class_Control_method_get_stylebox>`, and the ``add_*_override`` methods provided by this class.
  23. .. rst-class:: classref-introduction-group
  24. Tutorials
  25. ---------
  26. - :doc:`GUI tutorial index <../tutorials/ui/index>`
  27. - :doc:`Custom drawing in 2D <../tutorials/2d/custom_drawing_in_2d>`
  28. - :doc:`Control node gallery <../tutorials/ui/control_node_gallery>`
  29. - `All GUI Demos <https://github.com/godotengine/godot-demo-projects/tree/master/gui>`__
  30. .. rst-class:: classref-reftable-group
  31. Properties
  32. ----------
  33. .. table::
  34. :widths: auto
  35. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`anchor_bottom<class_Control_property_anchor_bottom>` | ``0.0`` |
  37. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`anchor_left<class_Control_property_anchor_left>` | ``0.0`` |
  39. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`anchor_right<class_Control_property_anchor_right>` | ``0.0`` |
  41. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`anchor_top<class_Control_property_anchor_top>` | ``0.0`` |
  43. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  44. | :ref:`FocusMode<enum_Control_FocusMode>` | :ref:`focus_mode<class_Control_property_focus_mode>` | ``0`` |
  45. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  46. | :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbour_bottom<class_Control_property_focus_neighbour_bottom>` | ``NodePath("")`` |
  47. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  48. | :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbour_left<class_Control_property_focus_neighbour_left>` | ``NodePath("")`` |
  49. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  50. | :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbour_right<class_Control_property_focus_neighbour_right>` | ``NodePath("")`` |
  51. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  52. | :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbour_top<class_Control_property_focus_neighbour_top>` | ``NodePath("")`` |
  53. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  54. | :ref:`NodePath<class_NodePath>` | :ref:`focus_next<class_Control_property_focus_next>` | ``NodePath("")`` |
  55. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  56. | :ref:`NodePath<class_NodePath>` | :ref:`focus_previous<class_Control_property_focus_previous>` | ``NodePath("")`` |
  57. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  58. | :ref:`GrowDirection<enum_Control_GrowDirection>` | :ref:`grow_horizontal<class_Control_property_grow_horizontal>` | ``1`` |
  59. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  60. | :ref:`GrowDirection<enum_Control_GrowDirection>` | :ref:`grow_vertical<class_Control_property_grow_vertical>` | ``1`` |
  61. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  62. | :ref:`String<class_String>` | :ref:`hint_tooltip<class_Control_property_hint_tooltip>` | ``""`` |
  63. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`input_pass_on_modal_close_click<class_Control_property_input_pass_on_modal_close_click>` | ``true`` |
  65. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  66. | :ref:`float<class_float>` | :ref:`margin_bottom<class_Control_property_margin_bottom>` | ``0.0`` |
  67. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  68. | :ref:`float<class_float>` | :ref:`margin_left<class_Control_property_margin_left>` | ``0.0`` |
  69. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`margin_right<class_Control_property_margin_right>` | ``0.0`` |
  71. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  72. | :ref:`float<class_float>` | :ref:`margin_top<class_Control_property_margin_top>` | ``0.0`` |
  73. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  74. | :ref:`CursorShape<enum_Control_CursorShape>` | :ref:`mouse_default_cursor_shape<class_Control_property_mouse_default_cursor_shape>` | ``0`` |
  75. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  76. | :ref:`MouseFilter<enum_Control_MouseFilter>` | :ref:`mouse_filter<class_Control_property_mouse_filter>` | ``0`` |
  77. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  78. | :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | physics_interpolation_mode | ``1`` (overrides :ref:`Node<class_Node_property_physics_interpolation_mode>`) |
  79. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  80. | :ref:`bool<class_bool>` | :ref:`rect_clip_content<class_Control_property_rect_clip_content>` | ``false`` |
  81. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  82. | :ref:`Vector2<class_Vector2>` | :ref:`rect_global_position<class_Control_property_rect_global_position>` | |
  83. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  84. | :ref:`Vector2<class_Vector2>` | :ref:`rect_min_size<class_Control_property_rect_min_size>` | ``Vector2( 0, 0 )`` |
  85. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  86. | :ref:`Vector2<class_Vector2>` | :ref:`rect_pivot_offset<class_Control_property_rect_pivot_offset>` | ``Vector2( 0, 0 )`` |
  87. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  88. | :ref:`Vector2<class_Vector2>` | :ref:`rect_position<class_Control_property_rect_position>` | ``Vector2( 0, 0 )`` |
  89. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`rect_rotation<class_Control_property_rect_rotation>` | ``0.0`` |
  91. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  92. | :ref:`Vector2<class_Vector2>` | :ref:`rect_scale<class_Control_property_rect_scale>` | ``Vector2( 1, 1 )`` |
  93. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  94. | :ref:`Vector2<class_Vector2>` | :ref:`rect_size<class_Control_property_rect_size>` | ``Vector2( 0, 0 )`` |
  95. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  96. | :ref:`int<class_int>` | :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` | ``1`` |
  97. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  98. | :ref:`float<class_float>` | :ref:`size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>` | ``1.0`` |
  99. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  100. | :ref:`int<class_int>` | :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` | ``1`` |
  101. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  102. | :ref:`Theme<class_Theme>` | :ref:`theme<class_Control_property_theme>` | |
  103. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  104. | :ref:`String<class_String>` | :ref:`theme_type_variation<class_Control_property_theme_type_variation>` | ``""`` |
  105. +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  106. .. rst-class:: classref-reftable-group
  107. Methods
  108. -------
  109. .. table::
  110. :widths: auto
  111. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`bool<class_bool>` | :ref:`_clips_input<class_Control_method__clips_input>` **(** **)** |virtual| |
  113. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Vector2<class_Vector2>` | :ref:`_get_minimum_size<class_Control_method__get_minimum_size>` **(** **)** |virtual| |
  115. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`_gui_input<class_Control_method__gui_input>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |virtual| |
  117. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`Control<class_Control>` | :ref:`_make_custom_tooltip<class_Control_method__make_custom_tooltip>` **(** :ref:`String<class_String>` for_text **)** |virtual| |
  119. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | void | :ref:`accept_event<class_Control_method_accept_event>` **(** **)** |
  121. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | void | :ref:`add_color_override<class_Control_method_add_color_override>` **(** :ref:`String<class_String>` name, :ref:`Color<class_Color>` color **)** |
  123. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`add_constant_override<class_Control_method_add_constant_override>` **(** :ref:`String<class_String>` name, :ref:`int<class_int>` constant **)** |
  125. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`add_font_override<class_Control_method_add_font_override>` **(** :ref:`String<class_String>` name, :ref:`Font<class_Font>` font **)** |
  127. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`add_icon_override<class_Control_method_add_icon_override>` **(** :ref:`String<class_String>` name, :ref:`Texture<class_Texture>` texture **)** |
  129. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`add_shader_override<class_Control_method_add_shader_override>` **(** :ref:`String<class_String>` name, :ref:`Shader<class_Shader>` shader **)** |
  131. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`add_stylebox_override<class_Control_method_add_stylebox_override>` **(** :ref:`String<class_String>` name, :ref:`StyleBox<class_StyleBox>` stylebox **)** |
  133. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`bool<class_bool>` | :ref:`can_drop_data<class_Control_method_can_drop_data>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data **)** |virtual| |
  135. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | void | :ref:`drop_data<class_Control_method_drop_data>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data **)** |virtual| |
  137. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Control<class_Control>` | :ref:`find_next_valid_focus<class_Control_method_find_next_valid_focus>` **(** **)** |const| |
  139. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`Control<class_Control>` | :ref:`find_prev_valid_focus<class_Control_method_find_prev_valid_focus>` **(** **)** |const| |
  141. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | void | :ref:`force_drag<class_Control_method_force_drag>` **(** :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` preview **)** |
  143. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`float<class_float>` | :ref:`get_anchor<class_Control_method_get_anchor>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  145. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`Vector2<class_Vector2>` | :ref:`get_begin<class_Control_method_get_begin>` **(** **)** |const| |
  147. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`Color<class_Color>` | :ref:`get_color<class_Control_method_get_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  149. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`Vector2<class_Vector2>` | :ref:`get_combined_minimum_size<class_Control_method_get_combined_minimum_size>` **(** **)** |const| |
  151. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | :ref:`int<class_int>` | :ref:`get_constant<class_Control_method_get_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  153. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | :ref:`CursorShape<enum_Control_CursorShape>` | :ref:`get_cursor_shape<class_Control_method_get_cursor_shape>` **(** :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)** |const| |
  155. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | :ref:`Variant<class_Variant>` | :ref:`get_drag_data<class_Control_method_get_drag_data>` **(** :ref:`Vector2<class_Vector2>` position **)** |virtual| |
  157. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | :ref:`Vector2<class_Vector2>` | :ref:`get_end<class_Control_method_get_end>` **(** **)** |const| |
  159. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | :ref:`NodePath<class_NodePath>` | :ref:`get_focus_neighbour<class_Control_method_get_focus_neighbour>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  161. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Control<class_Control>` | :ref:`get_focus_owner<class_Control_method_get_focus_owner>` **(** **)** |const| |
  163. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | :ref:`Font<class_Font>` | :ref:`get_font<class_Control_method_get_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  165. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. | :ref:`Rect2<class_Rect2>` | :ref:`get_global_rect<class_Control_method_get_global_rect>` **(** **)** |const| |
  167. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  168. | :ref:`Texture<class_Texture>` | :ref:`get_icon<class_Control_method_get_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  169. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  170. | :ref:`float<class_float>` | :ref:`get_margin<class_Control_method_get_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  171. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  172. | :ref:`Vector2<class_Vector2>` | :ref:`get_minimum_size<class_Control_method_get_minimum_size>` **(** **)** |const| |
  173. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  174. | :ref:`Vector2<class_Vector2>` | :ref:`get_parent_area_size<class_Control_method_get_parent_area_size>` **(** **)** |const| |
  175. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  176. | :ref:`Control<class_Control>` | :ref:`get_parent_control<class_Control_method_get_parent_control>` **(** **)** |const| |
  177. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  178. | :ref:`Rect2<class_Rect2>` | :ref:`get_rect<class_Control_method_get_rect>` **(** **)** |const| |
  179. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  180. | :ref:`float<class_float>` | :ref:`get_rotation<class_Control_method_get_rotation>` **(** **)** |const| |
  181. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  182. | :ref:`StyleBox<class_StyleBox>` | :ref:`get_stylebox<class_Control_method_get_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  183. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  184. | :ref:`Font<class_Font>` | :ref:`get_theme_default_font<class_Control_method_get_theme_default_font>` **(** **)** |const| |
  185. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  186. | :ref:`String<class_String>` | :ref:`get_tooltip<class_Control_method_get_tooltip>` **(** :ref:`Vector2<class_Vector2>` at_position=Vector2( 0, 0 ) **)** |const| |
  187. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  188. | void | :ref:`grab_click_focus<class_Control_method_grab_click_focus>` **(** **)** |
  189. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  190. | void | :ref:`grab_focus<class_Control_method_grab_focus>` **(** **)** |
  191. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  192. | :ref:`bool<class_bool>` | :ref:`has_color<class_Control_method_has_color>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  193. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  194. | :ref:`bool<class_bool>` | :ref:`has_color_override<class_Control_method_has_color_override>` **(** :ref:`String<class_String>` name **)** |const| |
  195. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  196. | :ref:`bool<class_bool>` | :ref:`has_constant<class_Control_method_has_constant>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  197. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  198. | :ref:`bool<class_bool>` | :ref:`has_constant_override<class_Control_method_has_constant_override>` **(** :ref:`String<class_String>` name **)** |const| |
  199. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  200. | :ref:`bool<class_bool>` | :ref:`has_focus<class_Control_method_has_focus>` **(** **)** |const| |
  201. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  202. | :ref:`bool<class_bool>` | :ref:`has_font<class_Control_method_has_font>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  203. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  204. | :ref:`bool<class_bool>` | :ref:`has_font_override<class_Control_method_has_font_override>` **(** :ref:`String<class_String>` name **)** |const| |
  205. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  206. | :ref:`bool<class_bool>` | :ref:`has_icon<class_Control_method_has_icon>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  207. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  208. | :ref:`bool<class_bool>` | :ref:`has_icon_override<class_Control_method_has_icon_override>` **(** :ref:`String<class_String>` name **)** |const| |
  209. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  210. | :ref:`bool<class_bool>` | :ref:`has_point<class_Control_method_has_point>` **(** :ref:`Vector2<class_Vector2>` point **)** |virtual| |
  211. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  212. | :ref:`bool<class_bool>` | :ref:`has_shader_override<class_Control_method_has_shader_override>` **(** :ref:`String<class_String>` name **)** |const| |
  213. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  214. | :ref:`bool<class_bool>` | :ref:`has_stylebox<class_Control_method_has_stylebox>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const| |
  215. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  216. | :ref:`bool<class_bool>` | :ref:`has_stylebox_override<class_Control_method_has_stylebox_override>` **(** :ref:`String<class_String>` name **)** |const| |
  217. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  218. | :ref:`bool<class_bool>` | :ref:`is_drag_successful<class_Control_method_is_drag_successful>` **(** **)** |const| |
  219. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  220. | void | :ref:`minimum_size_changed<class_Control_method_minimum_size_changed>` **(** **)** |
  221. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  222. | void | :ref:`release_focus<class_Control_method_release_focus>` **(** **)** |
  223. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  224. | void | :ref:`remove_color_override<class_Control_method_remove_color_override>` **(** :ref:`String<class_String>` name **)** |
  225. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  226. | void | :ref:`remove_constant_override<class_Control_method_remove_constant_override>` **(** :ref:`String<class_String>` name **)** |
  227. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  228. | void | :ref:`remove_font_override<class_Control_method_remove_font_override>` **(** :ref:`String<class_String>` name **)** |
  229. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  230. | void | :ref:`remove_icon_override<class_Control_method_remove_icon_override>` **(** :ref:`String<class_String>` name **)** |
  231. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  232. | void | :ref:`remove_shader_override<class_Control_method_remove_shader_override>` **(** :ref:`String<class_String>` name **)** |
  233. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  234. | void | :ref:`remove_stylebox_override<class_Control_method_remove_stylebox_override>` **(** :ref:`String<class_String>` name **)** |
  235. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  236. | void | :ref:`set_anchor<class_Control_method_set_anchor>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` anchor, :ref:`bool<class_bool>` keep_margin=false, :ref:`bool<class_bool>` push_opposite_anchor=true **)** |
  237. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  238. | void | :ref:`set_anchor_and_margin<class_Control_method_set_anchor_and_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` anchor, :ref:`float<class_float>` offset, :ref:`bool<class_bool>` push_opposite_anchor=false **)** |
  239. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  240. | void | :ref:`set_anchors_and_margins_preset<class_Control_method_set_anchors_and_margins_preset>` **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` resize_mode=0, :ref:`int<class_int>` margin=0 **)** |
  241. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  242. | void | :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`bool<class_bool>` keep_margins=false **)** |
  243. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  244. | void | :ref:`set_begin<class_Control_method_set_begin>` **(** :ref:`Vector2<class_Vector2>` position **)** |
  245. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  246. | void | :ref:`set_drag_forwarding<class_Control_method_set_drag_forwarding>` **(** :ref:`Control<class_Control>` target **)** |
  247. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  248. | void | :ref:`set_drag_preview<class_Control_method_set_drag_preview>` **(** :ref:`Control<class_Control>` control **)** |
  249. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  250. | void | :ref:`set_end<class_Control_method_set_end>` **(** :ref:`Vector2<class_Vector2>` position **)** |
  251. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  252. | void | :ref:`set_focus_neighbour<class_Control_method_set_focus_neighbour>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)** |
  253. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  254. | void | :ref:`set_global_position<class_Control_method_set_global_position>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` keep_margins=false **)** |
  255. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  256. | void | :ref:`set_margin<class_Control_method_set_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)** |
  257. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  258. | void | :ref:`set_margins_preset<class_Control_method_set_margins_preset>` **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` resize_mode=0, :ref:`int<class_int>` margin=0 **)** |
  259. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  260. | void | :ref:`set_position<class_Control_method_set_position>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` keep_margins=false **)** |
  261. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  262. | void | :ref:`set_rotation<class_Control_method_set_rotation>` **(** :ref:`float<class_float>` radians **)** |
  263. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  264. | void | :ref:`set_size<class_Control_method_set_size>` **(** :ref:`Vector2<class_Vector2>` size, :ref:`bool<class_bool>` keep_margins=false **)** |
  265. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  266. | void | :ref:`show_modal<class_Control_method_show_modal>` **(** :ref:`bool<class_bool>` exclusive=false **)** |
  267. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  268. | void | :ref:`warp_mouse<class_Control_method_warp_mouse>` **(** :ref:`Vector2<class_Vector2>` to_position **)** |
  269. +----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  270. .. rst-class:: classref-section-separator
  271. ----
  272. .. rst-class:: classref-descriptions-group
  273. Signals
  274. -------
  275. .. _class_Control_signal_focus_entered:
  276. .. rst-class:: classref-signal
  277. **focus_entered** **(** **)**
  278. Emitted when the node gains focus.
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_Control_signal_focus_exited:
  282. .. rst-class:: classref-signal
  283. **focus_exited** **(** **)**
  284. Emitted when the node loses focus.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_Control_signal_gui_input:
  288. .. rst-class:: classref-signal
  289. **gui_input** **(** :ref:`InputEvent<class_InputEvent>` event **)**
  290. Emitted when the node receives an :ref:`InputEvent<class_InputEvent>`.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_Control_signal_minimum_size_changed:
  294. .. rst-class:: classref-signal
  295. **minimum_size_changed** **(** **)**
  296. Emitted when the node's minimum size changes.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_Control_signal_modal_closed:
  300. .. rst-class:: classref-signal
  301. **modal_closed** **(** **)**
  302. Emitted when a modal **Control** is closed. See :ref:`show_modal<class_Control_method_show_modal>`.
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_Control_signal_mouse_entered:
  306. .. rst-class:: classref-signal
  307. **mouse_entered** **(** **)**
  308. Emitted when the mouse enters the control's ``Rect`` area, provided its :ref:`mouse_filter<class_Control_property_mouse_filter>` lets the event reach it.
  309. \ **Note:** :ref:`mouse_entered<class_Control_signal_mouse_entered>` will not be emitted if the mouse enters a child **Control** node before entering the parent's ``Rect`` area, at least until the mouse is moved to reach the parent's ``Rect`` area.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_Control_signal_mouse_exited:
  313. .. rst-class:: classref-signal
  314. **mouse_exited** **(** **)**
  315. Emitted when the mouse leaves the control's ``Rect`` area, provided its :ref:`mouse_filter<class_Control_property_mouse_filter>` lets the event reach it.
  316. \ **Note:** :ref:`mouse_exited<class_Control_signal_mouse_exited>` will be emitted if the mouse enters a child **Control** node, even if the mouse cursor is still inside the parent's ``Rect`` area.
  317. If you want to check whether the mouse truly left the area, ignoring any top nodes, you can use code like this:
  318. ::
  319. func _on_mouse_exited():
  320. if not Rect2(Vector2(), rect_size).has_point(get_local_mouse_position()):
  321. # Not hovering over area.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_Control_signal_resized:
  325. .. rst-class:: classref-signal
  326. **resized** **(** **)**
  327. Emitted when the control changes size.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_Control_signal_size_flags_changed:
  331. .. rst-class:: classref-signal
  332. **size_flags_changed** **(** **)**
  333. Emitted when one of the size flags changes. See :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` and :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`.
  334. .. rst-class:: classref-section-separator
  335. ----
  336. .. rst-class:: classref-descriptions-group
  337. Enumerations
  338. ------------
  339. .. _enum_Control_FocusMode:
  340. .. rst-class:: classref-enumeration
  341. enum **FocusMode**:
  342. .. _class_Control_constant_FOCUS_NONE:
  343. .. rst-class:: classref-enumeration-constant
  344. :ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_NONE** = ``0``
  345. The node cannot grab focus. Use with :ref:`focus_mode<class_Control_property_focus_mode>`.
  346. .. _class_Control_constant_FOCUS_CLICK:
  347. .. rst-class:: classref-enumeration-constant
  348. :ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_CLICK** = ``1``
  349. The node can only grab focus on mouse clicks. Use with :ref:`focus_mode<class_Control_property_focus_mode>`.
  350. .. _class_Control_constant_FOCUS_ALL:
  351. .. rst-class:: classref-enumeration-constant
  352. :ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_ALL** = ``2``
  353. The node can grab focus on mouse click, using the arrows and the Tab keys on the keyboard, or using the D-pad buttons on a gamepad. Use with :ref:`focus_mode<class_Control_property_focus_mode>`.
  354. .. rst-class:: classref-item-separator
  355. ----
  356. .. _enum_Control_CursorShape:
  357. .. rst-class:: classref-enumeration
  358. enum **CursorShape**:
  359. .. _class_Control_constant_CURSOR_ARROW:
  360. .. rst-class:: classref-enumeration-constant
  361. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_ARROW** = ``0``
  362. Show the system's arrow mouse cursor when the user hovers the node. Use with :ref:`mouse_default_cursor_shape<class_Control_property_mouse_default_cursor_shape>`.
  363. .. _class_Control_constant_CURSOR_IBEAM:
  364. .. rst-class:: classref-enumeration-constant
  365. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_IBEAM** = ``1``
  366. Show the system's I-beam mouse cursor when the user hovers the node. The I-beam pointer has a shape similar to "I". It tells the user they can highlight or insert text.
  367. .. _class_Control_constant_CURSOR_POINTING_HAND:
  368. .. rst-class:: classref-enumeration-constant
  369. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_POINTING_HAND** = ``2``
  370. Show the system's pointing hand mouse cursor when the user hovers the node.
  371. .. _class_Control_constant_CURSOR_CROSS:
  372. .. rst-class:: classref-enumeration-constant
  373. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_CROSS** = ``3``
  374. Show the system's cross mouse cursor when the user hovers the node.
  375. .. _class_Control_constant_CURSOR_WAIT:
  376. .. rst-class:: classref-enumeration-constant
  377. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_WAIT** = ``4``
  378. Show the system's wait mouse cursor when the user hovers the node. Often an hourglass.
  379. .. _class_Control_constant_CURSOR_BUSY:
  380. .. rst-class:: classref-enumeration-constant
  381. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_BUSY** = ``5``
  382. Show the system's busy mouse cursor when the user hovers the node. Often an arrow with a small hourglass.
  383. .. _class_Control_constant_CURSOR_DRAG:
  384. .. rst-class:: classref-enumeration-constant
  385. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_DRAG** = ``6``
  386. Show the system's drag mouse cursor, often a closed fist or a cross symbol, when the user hovers the node. It tells the user they're currently dragging an item, like a node in the Scene dock.
  387. .. _class_Control_constant_CURSOR_CAN_DROP:
  388. .. rst-class:: classref-enumeration-constant
  389. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_CAN_DROP** = ``7``
  390. Show the system's drop mouse cursor when the user hovers the node. It can be an open hand. It tells the user they can drop an item they're currently grabbing, like a node in the Scene dock.
  391. .. _class_Control_constant_CURSOR_FORBIDDEN:
  392. .. rst-class:: classref-enumeration-constant
  393. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_FORBIDDEN** = ``8``
  394. Show the system's forbidden mouse cursor when the user hovers the node. Often a crossed circle.
  395. .. _class_Control_constant_CURSOR_VSIZE:
  396. .. rst-class:: classref-enumeration-constant
  397. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_VSIZE** = ``9``
  398. Show the system's vertical resize mouse cursor when the user hovers the node. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
  399. .. _class_Control_constant_CURSOR_HSIZE:
  400. .. rst-class:: classref-enumeration-constant
  401. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HSIZE** = ``10``
  402. Show the system's horizontal resize mouse cursor when the user hovers the node. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
  403. .. _class_Control_constant_CURSOR_BDIAGSIZE:
  404. .. rst-class:: classref-enumeration-constant
  405. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_BDIAGSIZE** = ``11``
  406. Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
  407. .. _class_Control_constant_CURSOR_FDIAGSIZE:
  408. .. rst-class:: classref-enumeration-constant
  409. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_FDIAGSIZE** = ``12``
  410. Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of :ref:`CURSOR_BDIAGSIZE<class_Control_constant_CURSOR_BDIAGSIZE>`. It tells the user they can resize the window or the panel both horizontally and vertically.
  411. .. _class_Control_constant_CURSOR_MOVE:
  412. .. rst-class:: classref-enumeration-constant
  413. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_MOVE** = ``13``
  414. Show the system's move mouse cursor when the user hovers the node. It shows 2 double-headed arrows at a 90 degree angle. It tells the user they can move a UI element freely.
  415. .. _class_Control_constant_CURSOR_VSPLIT:
  416. .. rst-class:: classref-enumeration-constant
  417. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_VSPLIT** = ``14``
  418. Show the system's vertical split mouse cursor when the user hovers the node. On Windows, it's the same as :ref:`CURSOR_VSIZE<class_Control_constant_CURSOR_VSIZE>`.
  419. .. _class_Control_constant_CURSOR_HSPLIT:
  420. .. rst-class:: classref-enumeration-constant
  421. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HSPLIT** = ``15``
  422. Show the system's horizontal split mouse cursor when the user hovers the node. On Windows, it's the same as :ref:`CURSOR_HSIZE<class_Control_constant_CURSOR_HSIZE>`.
  423. .. _class_Control_constant_CURSOR_HELP:
  424. .. rst-class:: classref-enumeration-constant
  425. :ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HELP** = ``16``
  426. Show the system's help mouse cursor when the user hovers the node, a question mark.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _enum_Control_LayoutPreset:
  430. .. rst-class:: classref-enumeration
  431. enum **LayoutPreset**:
  432. .. _class_Control_constant_PRESET_TOP_LEFT:
  433. .. rst-class:: classref-enumeration-constant
  434. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_LEFT** = ``0``
  435. Snap all 4 anchors to the top-left of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  436. .. _class_Control_constant_PRESET_TOP_RIGHT:
  437. .. rst-class:: classref-enumeration-constant
  438. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_RIGHT** = ``1``
  439. Snap all 4 anchors to the top-right of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  440. .. _class_Control_constant_PRESET_BOTTOM_LEFT:
  441. .. rst-class:: classref-enumeration-constant
  442. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_LEFT** = ``2``
  443. Snap all 4 anchors to the bottom-left of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  444. .. _class_Control_constant_PRESET_BOTTOM_RIGHT:
  445. .. rst-class:: classref-enumeration-constant
  446. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_RIGHT** = ``3``
  447. Snap all 4 anchors to the bottom-right of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  448. .. _class_Control_constant_PRESET_CENTER_LEFT:
  449. .. rst-class:: classref-enumeration-constant
  450. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_LEFT** = ``4``
  451. Snap all 4 anchors to the center of the left edge of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  452. .. _class_Control_constant_PRESET_CENTER_TOP:
  453. .. rst-class:: classref-enumeration-constant
  454. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_TOP** = ``5``
  455. Snap all 4 anchors to the center of the top edge of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  456. .. _class_Control_constant_PRESET_CENTER_RIGHT:
  457. .. rst-class:: classref-enumeration-constant
  458. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_RIGHT** = ``6``
  459. Snap all 4 anchors to the center of the right edge of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  460. .. _class_Control_constant_PRESET_CENTER_BOTTOM:
  461. .. rst-class:: classref-enumeration-constant
  462. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_BOTTOM** = ``7``
  463. Snap all 4 anchors to the center of the bottom edge of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  464. .. _class_Control_constant_PRESET_CENTER:
  465. .. rst-class:: classref-enumeration-constant
  466. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER** = ``8``
  467. Snap all 4 anchors to the center of the parent control's bounds. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  468. .. _class_Control_constant_PRESET_LEFT_WIDE:
  469. .. rst-class:: classref-enumeration-constant
  470. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_LEFT_WIDE** = ``9``
  471. Snap all 4 anchors to the left edge of the parent control. The left margin becomes relative to the left edge and the top margin relative to the top left corner of the node's parent. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  472. .. _class_Control_constant_PRESET_TOP_WIDE:
  473. .. rst-class:: classref-enumeration-constant
  474. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_WIDE** = ``10``
  475. Snap all 4 anchors to the top edge of the parent control. The left margin becomes relative to the top left corner, the top margin relative to the top edge, and the right margin relative to the top right corner of the node's parent. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  476. .. _class_Control_constant_PRESET_RIGHT_WIDE:
  477. .. rst-class:: classref-enumeration-constant
  478. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_RIGHT_WIDE** = ``11``
  479. Snap all 4 anchors to the right edge of the parent control. The right margin becomes relative to the right edge and the top margin relative to the top right corner of the node's parent. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  480. .. _class_Control_constant_PRESET_BOTTOM_WIDE:
  481. .. rst-class:: classref-enumeration-constant
  482. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_WIDE** = ``12``
  483. Snap all 4 anchors to the bottom edge of the parent control. The left margin becomes relative to the bottom left corner, the bottom margin relative to the bottom edge, and the right margin relative to the bottom right corner of the node's parent. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  484. .. _class_Control_constant_PRESET_VCENTER_WIDE:
  485. .. rst-class:: classref-enumeration-constant
  486. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_VCENTER_WIDE** = ``13``
  487. Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  488. .. _class_Control_constant_PRESET_HCENTER_WIDE:
  489. .. rst-class:: classref-enumeration-constant
  490. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_HCENTER_WIDE** = ``14``
  491. Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  492. .. _class_Control_constant_PRESET_WIDE:
  493. .. rst-class:: classref-enumeration-constant
  494. :ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_WIDE** = ``15``
  495. Snap all 4 anchors to the respective corners of the parent control. Set all 4 margins to 0 after you applied this preset and the **Control** will fit its parent control. This is equivalent to the "Full Rect" layout option in the editor. Use with :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _enum_Control_LayoutPresetMode:
  499. .. rst-class:: classref-enumeration
  500. enum **LayoutPresetMode**:
  501. .. _class_Control_constant_PRESET_MODE_MINSIZE:
  502. .. rst-class:: classref-enumeration-constant
  503. :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_MINSIZE** = ``0``
  504. The control will be resized to its minimum size.
  505. .. _class_Control_constant_PRESET_MODE_KEEP_WIDTH:
  506. .. rst-class:: classref-enumeration-constant
  507. :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_WIDTH** = ``1``
  508. The control's width will not change.
  509. .. _class_Control_constant_PRESET_MODE_KEEP_HEIGHT:
  510. .. rst-class:: classref-enumeration-constant
  511. :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_HEIGHT** = ``2``
  512. The control's height will not change.
  513. .. _class_Control_constant_PRESET_MODE_KEEP_SIZE:
  514. .. rst-class:: classref-enumeration-constant
  515. :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_SIZE** = ``3``
  516. The control's size will not change.
  517. .. rst-class:: classref-item-separator
  518. ----
  519. .. _enum_Control_SizeFlags:
  520. .. rst-class:: classref-enumeration
  521. enum **SizeFlags**:
  522. .. _class_Control_constant_SIZE_FILL:
  523. .. rst-class:: classref-enumeration-constant
  524. :ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_FILL** = ``1``
  525. Tells the parent :ref:`Container<class_Container>` to expand the bounds of this node to fill all the available space without pushing any other node. Use with :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` and :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`.
  526. .. _class_Control_constant_SIZE_EXPAND:
  527. .. rst-class:: classref-enumeration-constant
  528. :ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_EXPAND** = ``2``
  529. Tells the parent :ref:`Container<class_Container>` to let this node take all the available space on the axis you flag. If multiple neighboring nodes are set to expand, they'll share the space based on their stretch ratio. See :ref:`size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>`. Use with :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` and :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`.
  530. .. _class_Control_constant_SIZE_EXPAND_FILL:
  531. .. rst-class:: classref-enumeration-constant
  532. :ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_EXPAND_FILL** = ``3``
  533. Sets the node's size flags to both fill and expand. See the 2 constants above for more information.
  534. .. _class_Control_constant_SIZE_SHRINK_CENTER:
  535. .. rst-class:: classref-enumeration-constant
  536. :ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_SHRINK_CENTER** = ``4``
  537. Tells the parent :ref:`Container<class_Container>` to center the node in itself. It centers the control based on its bounding box, so it doesn't work with the fill or expand size flags. Use with :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` and :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`.
  538. .. _class_Control_constant_SIZE_SHRINK_END:
  539. .. rst-class:: classref-enumeration-constant
  540. :ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_SHRINK_END** = ``8``
  541. Tells the parent :ref:`Container<class_Container>` to align the node with its end, either the bottom or the right edge. It doesn't work with the fill or expand size flags. Use with :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` and :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _enum_Control_MouseFilter:
  545. .. rst-class:: classref-enumeration
  546. enum **MouseFilter**:
  547. .. _class_Control_constant_MOUSE_FILTER_STOP:
  548. .. rst-class:: classref-enumeration-constant
  549. :ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_STOP** = ``0``
  550. The control will receive mouse button input events through :ref:`_gui_input<class_Control_method__gui_input>` if clicked on. And the control will receive the :ref:`mouse_entered<class_Control_signal_mouse_entered>` and :ref:`mouse_exited<class_Control_signal_mouse_exited>` signals. These events are automatically marked as handled, and they will not propagate further to other controls. This also results in blocking signals in other controls.
  551. .. _class_Control_constant_MOUSE_FILTER_PASS:
  552. .. rst-class:: classref-enumeration-constant
  553. :ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_PASS** = ``1``
  554. The control will receive mouse button input events through :ref:`_gui_input<class_Control_method__gui_input>` if clicked on. And the control will receive the :ref:`mouse_entered<class_Control_signal_mouse_entered>` and :ref:`mouse_exited<class_Control_signal_mouse_exited>` signals. If this control does not handle the event, the parent control (if any) will be considered, and so on until there is no more parent control to potentially handle it. This also allows signals to fire in other controls. Even if no control handled it at all, the event will still be handled automatically, so unhandled input will not be fired.
  555. .. _class_Control_constant_MOUSE_FILTER_IGNORE:
  556. .. rst-class:: classref-enumeration-constant
  557. :ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_IGNORE** = ``2``
  558. The control will not receive mouse button input events through :ref:`_gui_input<class_Control_method__gui_input>`. The control will also not receive the :ref:`mouse_entered<class_Control_signal_mouse_entered>` nor :ref:`mouse_exited<class_Control_signal_mouse_exited>` signals. This will not block other controls from receiving these events or firing the signals. Ignored events will not be handled automatically.
  559. .. rst-class:: classref-item-separator
  560. ----
  561. .. _enum_Control_GrowDirection:
  562. .. rst-class:: classref-enumeration
  563. enum **GrowDirection**:
  564. .. _class_Control_constant_GROW_DIRECTION_BEGIN:
  565. .. rst-class:: classref-enumeration-constant
  566. :ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_BEGIN** = ``0``
  567. The control will grow to the left or top to make up if its minimum size is changed to be greater than its current size on the respective axis.
  568. .. _class_Control_constant_GROW_DIRECTION_END:
  569. .. rst-class:: classref-enumeration-constant
  570. :ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_END** = ``1``
  571. The control will grow to the right or bottom to make up if its minimum size is changed to be greater than its current size on the respective axis.
  572. .. _class_Control_constant_GROW_DIRECTION_BOTH:
  573. .. rst-class:: classref-enumeration-constant
  574. :ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_BOTH** = ``2``
  575. The control will grow in both directions equally to make up if its minimum size is changed to be greater than its current size.
  576. .. rst-class:: classref-item-separator
  577. ----
  578. .. _enum_Control_Anchor:
  579. .. rst-class:: classref-enumeration
  580. enum **Anchor**:
  581. .. _class_Control_constant_ANCHOR_BEGIN:
  582. .. rst-class:: classref-enumeration-constant
  583. :ref:`Anchor<enum_Control_Anchor>` **ANCHOR_BEGIN** = ``0``
  584. Snaps one of the 4 anchor's sides to the origin of the node's ``Rect``, in the top left. Use it with one of the ``anchor_*`` member variables, like :ref:`anchor_left<class_Control_property_anchor_left>`. To change all 4 anchors at once, use :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  585. .. _class_Control_constant_ANCHOR_END:
  586. .. rst-class:: classref-enumeration-constant
  587. :ref:`Anchor<enum_Control_Anchor>` **ANCHOR_END** = ``1``
  588. Snaps one of the 4 anchor's sides to the end of the node's ``Rect``, in the bottom right. Use it with one of the ``anchor_*`` member variables, like :ref:`anchor_left<class_Control_property_anchor_left>`. To change all 4 anchors at once, use :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`.
  589. .. rst-class:: classref-section-separator
  590. ----
  591. .. rst-class:: classref-descriptions-group
  592. Constants
  593. ---------
  594. .. _class_Control_constant_NOTIFICATION_RESIZED:
  595. .. rst-class:: classref-constant
  596. **NOTIFICATION_RESIZED** = ``40``
  597. Sent when the node changes size. Use :ref:`rect_size<class_Control_property_rect_size>` to get the new size.
  598. .. _class_Control_constant_NOTIFICATION_MOUSE_ENTER:
  599. .. rst-class:: classref-constant
  600. **NOTIFICATION_MOUSE_ENTER** = ``41``
  601. Sent when the mouse pointer enters the node.
  602. .. _class_Control_constant_NOTIFICATION_MOUSE_EXIT:
  603. .. rst-class:: classref-constant
  604. **NOTIFICATION_MOUSE_EXIT** = ``42``
  605. Sent when the mouse pointer exits the node.
  606. .. _class_Control_constant_NOTIFICATION_FOCUS_ENTER:
  607. .. rst-class:: classref-constant
  608. **NOTIFICATION_FOCUS_ENTER** = ``43``
  609. Sent when the node grabs focus.
  610. .. _class_Control_constant_NOTIFICATION_FOCUS_EXIT:
  611. .. rst-class:: classref-constant
  612. **NOTIFICATION_FOCUS_EXIT** = ``44``
  613. Sent when the node loses focus.
  614. .. _class_Control_constant_NOTIFICATION_THEME_CHANGED:
  615. .. rst-class:: classref-constant
  616. **NOTIFICATION_THEME_CHANGED** = ``45``
  617. Sent when the node's :ref:`theme<class_Control_property_theme>` changes, right before Godot redraws the control. Happens when you call one of the ``add_*_override`` methods.
  618. .. _class_Control_constant_NOTIFICATION_MODAL_CLOSE:
  619. .. rst-class:: classref-constant
  620. **NOTIFICATION_MODAL_CLOSE** = ``46``
  621. Sent when an open modal dialog closes. See :ref:`show_modal<class_Control_method_show_modal>`.
  622. .. _class_Control_constant_NOTIFICATION_SCROLL_BEGIN:
  623. .. rst-class:: classref-constant
  624. **NOTIFICATION_SCROLL_BEGIN** = ``47``
  625. Sent when this node is inside a :ref:`ScrollContainer<class_ScrollContainer>` which has begun being scrolled.
  626. .. _class_Control_constant_NOTIFICATION_SCROLL_END:
  627. .. rst-class:: classref-constant
  628. **NOTIFICATION_SCROLL_END** = ``48``
  629. Sent when this node is inside a :ref:`ScrollContainer<class_ScrollContainer>` which has stopped being scrolled.
  630. .. rst-class:: classref-section-separator
  631. ----
  632. .. rst-class:: classref-descriptions-group
  633. Property Descriptions
  634. ---------------------
  635. .. _class_Control_property_anchor_bottom:
  636. .. rst-class:: classref-property
  637. :ref:`float<class_float>` **anchor_bottom** = ``0.0``
  638. .. rst-class:: classref-property-setget
  639. - :ref:`float<class_float>` **get_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  640. 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 :ref:`Anchor<enum_Control_Anchor>` constants for convenience.
  641. .. rst-class:: classref-item-separator
  642. ----
  643. .. _class_Control_property_anchor_left:
  644. .. rst-class:: classref-property
  645. :ref:`float<class_float>` **anchor_left** = ``0.0``
  646. .. rst-class:: classref-property-setget
  647. - :ref:`float<class_float>` **get_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  648. 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 :ref:`Anchor<enum_Control_Anchor>` constants for convenience.
  649. .. rst-class:: classref-item-separator
  650. ----
  651. .. _class_Control_property_anchor_right:
  652. .. rst-class:: classref-property
  653. :ref:`float<class_float>` **anchor_right** = ``0.0``
  654. .. rst-class:: classref-property-setget
  655. - :ref:`float<class_float>` **get_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  656. 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 :ref:`Anchor<enum_Control_Anchor>` constants for convenience.
  657. .. rst-class:: classref-item-separator
  658. ----
  659. .. _class_Control_property_anchor_top:
  660. .. rst-class:: classref-property
  661. :ref:`float<class_float>` **anchor_top** = ``0.0``
  662. .. rst-class:: classref-property-setget
  663. - :ref:`float<class_float>` **get_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  664. 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 :ref:`Anchor<enum_Control_Anchor>` constants for convenience.
  665. .. rst-class:: classref-item-separator
  666. ----
  667. .. _class_Control_property_focus_mode:
  668. .. rst-class:: classref-property
  669. :ref:`FocusMode<enum_Control_FocusMode>` **focus_mode** = ``0``
  670. .. rst-class:: classref-property-setget
  671. - void **set_focus_mode** **(** :ref:`FocusMode<enum_Control_FocusMode>` value **)**
  672. - :ref:`FocusMode<enum_Control_FocusMode>` **get_focus_mode** **(** **)**
  673. 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, gamepad, and mouse signals.
  674. .. rst-class:: classref-item-separator
  675. ----
  676. .. _class_Control_property_focus_neighbour_bottom:
  677. .. rst-class:: classref-property
  678. :ref:`NodePath<class_NodePath>` **focus_neighbour_bottom** = ``NodePath("")``
  679. .. rst-class:: classref-property-setget
  680. - void **set_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)**
  681. - :ref:`NodePath<class_NodePath>` **get_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  682. Tells Godot which node it should give 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.
  683. .. rst-class:: classref-item-separator
  684. ----
  685. .. _class_Control_property_focus_neighbour_left:
  686. .. rst-class:: classref-property
  687. :ref:`NodePath<class_NodePath>` **focus_neighbour_left** = ``NodePath("")``
  688. .. rst-class:: classref-property-setget
  689. - void **set_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)**
  690. - :ref:`NodePath<class_NodePath>` **get_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  691. Tells Godot which node it should give 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.
  692. .. rst-class:: classref-item-separator
  693. ----
  694. .. _class_Control_property_focus_neighbour_right:
  695. .. rst-class:: classref-property
  696. :ref:`NodePath<class_NodePath>` **focus_neighbour_right** = ``NodePath("")``
  697. .. rst-class:: classref-property-setget
  698. - void **set_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)**
  699. - :ref:`NodePath<class_NodePath>` **get_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  700. Tells Godot which node it should give 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.
  701. .. rst-class:: classref-item-separator
  702. ----
  703. .. _class_Control_property_focus_neighbour_top:
  704. .. rst-class:: classref-property
  705. :ref:`NodePath<class_NodePath>` **focus_neighbour_top** = ``NodePath("")``
  706. .. rst-class:: classref-property-setget
  707. - void **set_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)**
  708. - :ref:`NodePath<class_NodePath>` **get_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  709. Tells Godot which node it should give 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.
  710. .. rst-class:: classref-item-separator
  711. ----
  712. .. _class_Control_property_focus_next:
  713. .. rst-class:: classref-property
  714. :ref:`NodePath<class_NodePath>` **focus_next** = ``NodePath("")``
  715. .. rst-class:: classref-property-setget
  716. - void **set_focus_next** **(** :ref:`NodePath<class_NodePath>` value **)**
  717. - :ref:`NodePath<class_NodePath>` **get_focus_next** **(** **)**
  718. Tells Godot which node it should give focus to if the user presses :kbd:`Tab` on a keyboard by default. You can change the key by editing the ``ui_focus_next`` input action.
  719. If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
  720. .. rst-class:: classref-item-separator
  721. ----
  722. .. _class_Control_property_focus_previous:
  723. .. rst-class:: classref-property
  724. :ref:`NodePath<class_NodePath>` **focus_previous** = ``NodePath("")``
  725. .. rst-class:: classref-property-setget
  726. - void **set_focus_previous** **(** :ref:`NodePath<class_NodePath>` value **)**
  727. - :ref:`NodePath<class_NodePath>` **get_focus_previous** **(** **)**
  728. Tells Godot which node it should give focus to if the user presses :kbd:`Shift + Tab` on a keyboard by default. You can change the key by editing the ``ui_focus_prev`` input action.
  729. If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
  730. .. rst-class:: classref-item-separator
  731. ----
  732. .. _class_Control_property_grow_horizontal:
  733. .. rst-class:: classref-property
  734. :ref:`GrowDirection<enum_Control_GrowDirection>` **grow_horizontal** = ``1``
  735. .. rst-class:: classref-property-setget
  736. - void **set_h_grow_direction** **(** :ref:`GrowDirection<enum_Control_GrowDirection>` value **)**
  737. - :ref:`GrowDirection<enum_Control_GrowDirection>` **get_h_grow_direction** **(** **)**
  738. 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.
  739. .. rst-class:: classref-item-separator
  740. ----
  741. .. _class_Control_property_grow_vertical:
  742. .. rst-class:: classref-property
  743. :ref:`GrowDirection<enum_Control_GrowDirection>` **grow_vertical** = ``1``
  744. .. rst-class:: classref-property-setget
  745. - void **set_v_grow_direction** **(** :ref:`GrowDirection<enum_Control_GrowDirection>` value **)**
  746. - :ref:`GrowDirection<enum_Control_GrowDirection>` **get_v_grow_direction** **(** **)**
  747. 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.
  748. .. rst-class:: classref-item-separator
  749. ----
  750. .. _class_Control_property_hint_tooltip:
  751. .. rst-class:: classref-property
  752. :ref:`String<class_String>` **hint_tooltip** = ``""``
  753. .. rst-class:: classref-property-setget
  754. - void **set_tooltip** **(** :ref:`String<class_String>` value **)**
  755. 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 :ref:`mouse_filter<class_Control_property_mouse_filter>` property is not :ref:`MOUSE_FILTER_IGNORE<class_Control_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.
  756. The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding :ref:`_make_custom_tooltip<class_Control_method__make_custom_tooltip>`. The default tooltip includes a :ref:`PopupPanel<class_PopupPanel>` and :ref:`Label<class_Label>` whose theme properties can be customized using :ref:`Theme<class_Theme>` methods with the ``"TooltipPanel"`` and ``"TooltipLabel"`` respectively. For example:
  757. ::
  758. var style_box = StyleBoxFlat.new()
  759. style_box.set_bg_color(Color(1, 1, 0))
  760. style_box.set_border_width_all(2)
  761. # We assume here that the `theme` property has been assigned a custom Theme beforehand.
  762. theme.set_stylebox("panel", "TooltipPanel", style_box)
  763. theme.set_color("font_color", "TooltipLabel", Color(0, 1, 1))
  764. .. rst-class:: classref-item-separator
  765. ----
  766. .. _class_Control_property_input_pass_on_modal_close_click:
  767. .. rst-class:: classref-property
  768. :ref:`bool<class_bool>` **input_pass_on_modal_close_click** = ``true``
  769. .. rst-class:: classref-property-setget
  770. - void **set_pass_on_modal_close_click** **(** :ref:`bool<class_bool>` value **)**
  771. - :ref:`bool<class_bool>` **get_pass_on_modal_close_click** **(** **)**
  772. Enables whether input should propagate when you close the control as modal.
  773. If ``false``, stops event handling at the viewport input event handling. The viewport first hides the modal and after marks the input as handled.
  774. .. rst-class:: classref-item-separator
  775. ----
  776. .. _class_Control_property_margin_bottom:
  777. .. rst-class:: classref-property
  778. :ref:`float<class_float>` **margin_bottom** = ``0.0``
  779. .. rst-class:: classref-property-setget
  780. - void **set_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)**
  781. - :ref:`float<class_float>` **get_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  782. Distance between the node's bottom edge and its parent control, based on :ref:`anchor_bottom<class_Control_property_anchor_bottom>`.
  783. Margins are often controlled by one or multiple parent :ref:`Container<class_Container>` nodes, so you should not modify them manually if your node is a direct child of a :ref:`Container<class_Container>`. Margins update automatically when you move or resize the node.
  784. .. rst-class:: classref-item-separator
  785. ----
  786. .. _class_Control_property_margin_left:
  787. .. rst-class:: classref-property
  788. :ref:`float<class_float>` **margin_left** = ``0.0``
  789. .. rst-class:: classref-property-setget
  790. - void **set_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)**
  791. - :ref:`float<class_float>` **get_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  792. Distance between the node's left edge and its parent control, based on :ref:`anchor_left<class_Control_property_anchor_left>`.
  793. Margins are often controlled by one or multiple parent :ref:`Container<class_Container>` nodes, so you should not modify them manually if your node is a direct child of a :ref:`Container<class_Container>`. Margins update automatically when you move or resize the node.
  794. .. rst-class:: classref-item-separator
  795. ----
  796. .. _class_Control_property_margin_right:
  797. .. rst-class:: classref-property
  798. :ref:`float<class_float>` **margin_right** = ``0.0``
  799. .. rst-class:: classref-property-setget
  800. - void **set_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)**
  801. - :ref:`float<class_float>` **get_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  802. Distance between the node's right edge and its parent control, based on :ref:`anchor_right<class_Control_property_anchor_right>`.
  803. Margins are often controlled by one or multiple parent :ref:`Container<class_Container>` nodes, so you should not modify them manually if your node is a direct child of a :ref:`Container<class_Container>`. Margins update automatically when you move or resize the node.
  804. .. rst-class:: classref-item-separator
  805. ----
  806. .. _class_Control_property_margin_top:
  807. .. rst-class:: classref-property
  808. :ref:`float<class_float>` **margin_top** = ``0.0``
  809. .. rst-class:: classref-property-setget
  810. - void **set_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)**
  811. - :ref:`float<class_float>` **get_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  812. Distance between the node's top edge and its parent control, based on :ref:`anchor_top<class_Control_property_anchor_top>`.
  813. Margins are often controlled by one or multiple parent :ref:`Container<class_Container>` nodes, so you should not modify them manually if your node is a direct child of a :ref:`Container<class_Container>`. Margins update automatically when you move or resize the node.
  814. .. rst-class:: classref-item-separator
  815. ----
  816. .. _class_Control_property_mouse_default_cursor_shape:
  817. .. rst-class:: classref-property
  818. :ref:`CursorShape<enum_Control_CursorShape>` **mouse_default_cursor_shape** = ``0``
  819. .. rst-class:: classref-property-setget
  820. - void **set_default_cursor_shape** **(** :ref:`CursorShape<enum_Control_CursorShape>` value **)**
  821. - :ref:`CursorShape<enum_Control_CursorShape>` **get_default_cursor_shape** **(** **)**
  822. The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors.
  823. \ **Note:** On Linux, shapes may vary depending on the cursor theme of the system.
  824. .. rst-class:: classref-item-separator
  825. ----
  826. .. _class_Control_property_mouse_filter:
  827. .. rst-class:: classref-property
  828. :ref:`MouseFilter<enum_Control_MouseFilter>` **mouse_filter** = ``0``
  829. .. rst-class:: classref-property-setget
  830. - void **set_mouse_filter** **(** :ref:`MouseFilter<enum_Control_MouseFilter>` value **)**
  831. - :ref:`MouseFilter<enum_Control_MouseFilter>` **get_mouse_filter** **(** **)**
  832. Controls whether the control will be able to receive mouse button input events through :ref:`_gui_input<class_Control_method__gui_input>` and how these events should be handled. Also controls whether the control can receive the :ref:`mouse_entered<class_Control_signal_mouse_entered>`, and :ref:`mouse_exited<class_Control_signal_mouse_exited>` signals. See the constants to learn what each does.
  833. .. rst-class:: classref-item-separator
  834. ----
  835. .. _class_Control_property_rect_clip_content:
  836. .. rst-class:: classref-property
  837. :ref:`bool<class_bool>` **rect_clip_content** = ``false``
  838. .. rst-class:: classref-property-setget
  839. - void **set_clip_contents** **(** :ref:`bool<class_bool>` value **)**
  840. - :ref:`bool<class_bool>` **is_clipping_contents** **(** **)**
  841. Enables whether rendering of :ref:`CanvasItem<class_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.
  842. .. rst-class:: classref-item-separator
  843. ----
  844. .. _class_Control_property_rect_global_position:
  845. .. rst-class:: classref-property
  846. :ref:`Vector2<class_Vector2>` **rect_global_position**
  847. .. rst-class:: classref-property-setget
  848. - :ref:`Vector2<class_Vector2>` **get_global_position** **(** **)**
  849. The node's global position, relative to the world (usually to the top-left corner of the window).
  850. .. rst-class:: classref-item-separator
  851. ----
  852. .. _class_Control_property_rect_min_size:
  853. .. rst-class:: classref-property
  854. :ref:`Vector2<class_Vector2>` **rect_min_size** = ``Vector2( 0, 0 )``
  855. .. rst-class:: classref-property-setget
  856. - void **set_custom_minimum_size** **(** :ref:`Vector2<class_Vector2>` value **)**
  857. - :ref:`Vector2<class_Vector2>` **get_custom_minimum_size** **(** **)**
  858. 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.
  859. .. rst-class:: classref-item-separator
  860. ----
  861. .. _class_Control_property_rect_pivot_offset:
  862. .. rst-class:: classref-property
  863. :ref:`Vector2<class_Vector2>` **rect_pivot_offset** = ``Vector2( 0, 0 )``
  864. .. rst-class:: classref-property-setget
  865. - void **set_pivot_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  866. - :ref:`Vector2<class_Vector2>` **get_pivot_offset** **(** **)**
  867. By default, the node's pivot is its top-left corner. When you change its :ref:`rect_rotation<class_Control_property_rect_rotation>` or :ref:`rect_scale<class_Control_property_rect_scale>`, it will rotate or scale around this pivot. Set this property to :ref:`rect_size<class_Control_property_rect_size>` / 2 to pivot around the Control's center.
  868. .. rst-class:: classref-item-separator
  869. ----
  870. .. _class_Control_property_rect_position:
  871. .. rst-class:: classref-property
  872. :ref:`Vector2<class_Vector2>` **rect_position** = ``Vector2( 0, 0 )``
  873. .. rst-class:: classref-property-setget
  874. - :ref:`Vector2<class_Vector2>` **get_position** **(** **)**
  875. The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by :ref:`rect_pivot_offset<class_Control_property_rect_pivot_offset>`.
  876. .. rst-class:: classref-item-separator
  877. ----
  878. .. _class_Control_property_rect_rotation:
  879. .. rst-class:: classref-property
  880. :ref:`float<class_float>` **rect_rotation** = ``0.0``
  881. .. rst-class:: classref-property-setget
  882. - void **set_rotation_degrees** **(** :ref:`float<class_float>` value **)**
  883. - :ref:`float<class_float>` **get_rotation_degrees** **(** **)**
  884. The node's rotation around its pivot, in degrees. See :ref:`rect_pivot_offset<class_Control_property_rect_pivot_offset>` to change the pivot's position.
  885. .. rst-class:: classref-item-separator
  886. ----
  887. .. _class_Control_property_rect_scale:
  888. .. rst-class:: classref-property
  889. :ref:`Vector2<class_Vector2>` **rect_scale** = ``Vector2( 1, 1 )``
  890. .. rst-class:: classref-property-setget
  891. - void **set_scale** **(** :ref:`Vector2<class_Vector2>` value **)**
  892. - :ref:`Vector2<class_Vector2>` **get_scale** **(** **)**
  893. The node's scale, relative to its :ref:`rect_size<class_Control_property_rect_size>`. Change this property to scale the node around its :ref:`rect_pivot_offset<class_Control_property_rect_pivot_offset>`. The Control's :ref:`hint_tooltip<class_Control_property_hint_tooltip>` will also scale according to this value.
  894. \ **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 :doc:`documentation <../tutorials/rendering/multiple_resolutions>` instead of scaling Controls individually.
  895. \ **Note:** If the Control node is a child of a :ref:`Container<class_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 :ref:`rect_scale<class_Control_property_rect_scale>` property.
  896. .. rst-class:: classref-item-separator
  897. ----
  898. .. _class_Control_property_rect_size:
  899. .. rst-class:: classref-property
  900. :ref:`Vector2<class_Vector2>` **rect_size** = ``Vector2( 0, 0 )``
  901. .. rst-class:: classref-property-setget
  902. - :ref:`Vector2<class_Vector2>` **get_size** **(** **)**
  903. The size of the node's bounding rectangle, in pixels. :ref:`Container<class_Container>` nodes update this property automatically.
  904. .. rst-class:: classref-item-separator
  905. ----
  906. .. _class_Control_property_size_flags_horizontal:
  907. .. rst-class:: classref-property
  908. :ref:`int<class_int>` **size_flags_horizontal** = ``1``
  909. .. rst-class:: classref-property-setget
  910. - void **set_h_size_flags** **(** :ref:`int<class_int>` value **)**
  911. - :ref:`int<class_int>` **get_h_size_flags** **(** **)**
  912. Tells the parent :ref:`Container<class_Container>` nodes how they should resize and place the node on the X axis. Use one of the :ref:`SizeFlags<enum_Control_SizeFlags>` constants to change the flags. See the constants to learn what each does.
  913. .. rst-class:: classref-item-separator
  914. ----
  915. .. _class_Control_property_size_flags_stretch_ratio:
  916. .. rst-class:: classref-property
  917. :ref:`float<class_float>` **size_flags_stretch_ratio** = ``1.0``
  918. .. rst-class:: classref-property-setget
  919. - void **set_stretch_ratio** **(** :ref:`float<class_float>` value **)**
  920. - :ref:`float<class_float>` **get_stretch_ratio** **(** **)**
  921. If the node and at least one of its neighbours uses the :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` size flag, the parent :ref:`Container<class_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.
  922. .. rst-class:: classref-item-separator
  923. ----
  924. .. _class_Control_property_size_flags_vertical:
  925. .. rst-class:: classref-property
  926. :ref:`int<class_int>` **size_flags_vertical** = ``1``
  927. .. rst-class:: classref-property-setget
  928. - void **set_v_size_flags** **(** :ref:`int<class_int>` value **)**
  929. - :ref:`int<class_int>` **get_v_size_flags** **(** **)**
  930. Tells the parent :ref:`Container<class_Container>` nodes how they should resize and place the node on the Y axis. Use one of the :ref:`SizeFlags<enum_Control_SizeFlags>` constants to change the flags. See the constants to learn what each does.
  931. .. rst-class:: classref-item-separator
  932. ----
  933. .. _class_Control_property_theme:
  934. .. rst-class:: classref-property
  935. :ref:`Theme<class_Theme>` **theme**
  936. .. rst-class:: classref-property-setget
  937. - void **set_theme** **(** :ref:`Theme<class_Theme>` value **)**
  938. - :ref:`Theme<class_Theme>` **get_theme** **(** **)**
  939. Changing this property replaces the current :ref:`Theme<class_Theme>` resource this node and all its **Control** children use.
  940. .. rst-class:: classref-item-separator
  941. ----
  942. .. _class_Control_property_theme_type_variation:
  943. .. rst-class:: classref-property
  944. :ref:`String<class_String>` **theme_type_variation** = ``""``
  945. .. rst-class:: classref-property-setget
  946. - void **set_theme_type_variation** **(** :ref:`String<class_String>` value **)**
  947. - :ref:`String<class_String>` **get_theme_type_variation** **(** **)**
  948. The name of a theme type variation used by this **Control** to look up its own theme items. When empty, the class name of the node is used (e.g. ``Button`` for the :ref:`Button<class_Button>` control), as well as the class names of all parent classes (in order of inheritance).
  949. When set, this property gives the highest priority to the type of the specified name. This type can in turn extend another type, forming a dependency chain. See :ref:`Theme.set_type_variation<class_Theme_method_set_type_variation>`. If the theme item cannot be found using this type or its base types, lookup falls back on the class names.
  950. \ **Note:** To look up **Control**'s own items use various ``get_*`` methods without specifying ``theme_type``.
  951. \ **Note:** Theme items are looked for in the tree order, from branch to root, where each **Control** node is checked for its :ref:`theme<class_Control_property_theme>` property. The earliest match against any type/class name is returned. The project-level Theme and the default Theme are checked last.
  952. .. rst-class:: classref-section-separator
  953. ----
  954. .. rst-class:: classref-descriptions-group
  955. Method Descriptions
  956. -------------------
  957. .. _class_Control_method__clips_input:
  958. .. rst-class:: classref-method
  959. :ref:`bool<class_bool>` **_clips_input** **(** **)** |virtual|
  960. Virtual method to be implemented by the user. Returns whether :ref:`_gui_input<class_Control_method__gui_input>` should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this **Control**. Similar to :ref:`rect_clip_content<class_Control_property_rect_clip_content>`, but doesn't affect visibility.
  961. If not overridden, defaults to ``false``.
  962. .. rst-class:: classref-item-separator
  963. ----
  964. .. _class_Control_method__get_minimum_size:
  965. .. rst-class:: classref-method
  966. :ref:`Vector2<class_Vector2>` **_get_minimum_size** **(** **)** |virtual|
  967. Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to :ref:`rect_min_size<class_Control_property_rect_min_size>` for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately).
  968. If not overridden, defaults to :ref:`Vector2.ZERO<class_Vector2_constant_ZERO>`.
  969. \ **Note:** This method will not be called when the script is attached to a **Control** node that already overrides its minimum size (e.g. :ref:`Label<class_Label>`, :ref:`Button<class_Button>`, :ref:`PanelContainer<class_PanelContainer>` etc.). It can only be used with most basic GUI nodes, like **Control**, :ref:`Container<class_Container>`, :ref:`Panel<class_Panel>` etc.
  970. .. rst-class:: classref-item-separator
  971. ----
  972. .. _class_Control_method__gui_input:
  973. .. rst-class:: classref-method
  974. void **_gui_input** **(** :ref:`InputEvent<class_InputEvent>` event **)** |virtual|
  975. Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See :ref:`accept_event<class_Control_method_accept_event>`.
  976. Example: clicking a control.
  977. ::
  978. func _gui_input(event):
  979. if event is InputEventMouseButton:
  980. if event.button_index == BUTTON_LEFT and event.pressed:
  981. print("I've been clicked D:")
  982. The event won't trigger if:
  983. \* clicking outside the control (see :ref:`has_point<class_Control_method_has_point>`);
  984. \* control has :ref:`mouse_filter<class_Control_property_mouse_filter>` set to :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>`;
  985. \* control is obstructed by another **Control** on top of it, which doesn't have :ref:`mouse_filter<class_Control_property_mouse_filter>` set to :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>`;
  986. \* control's parent has :ref:`mouse_filter<class_Control_property_mouse_filter>` set to :ref:`MOUSE_FILTER_STOP<class_Control_constant_MOUSE_FILTER_STOP>` or has accepted the event;
  987. \* it happens outside the parent's rectangle and the parent has either :ref:`rect_clip_content<class_Control_property_rect_clip_content>` or :ref:`_clips_input<class_Control_method__clips_input>` enabled.
  988. \ **Note:** Event position is relative to the control origin.
  989. .. rst-class:: classref-item-separator
  990. ----
  991. .. _class_Control_method__make_custom_tooltip:
  992. .. rst-class:: classref-method
  993. :ref:`Control<class_Control>` **_make_custom_tooltip** **(** :ref:`String<class_String>` for_text **)** |virtual|
  994. 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 :ref:`hint_tooltip<class_Control_property_hint_tooltip>` property.
  995. 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.
  996. The returned node will be added as child to a :ref:`PopupPanel<class_PopupPanel>`, so you should only provide the contents of that panel. That :ref:`PopupPanel<class_PopupPanel>` can be themed using :ref:`Theme.set_stylebox<class_Theme_method_set_stylebox>` for the type ``"TooltipPanel"`` (see :ref:`hint_tooltip<class_Control_property_hint_tooltip>` for an example).
  997. \ **Note:** The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its :ref:`rect_min_size<class_Control_property_rect_min_size>` to some non-zero value.
  998. Example of usage with a custom-constructed node:
  999. ::
  1000. func _make_custom_tooltip(for_text):
  1001. var label = Label.new()
  1002. label.text = for_text
  1003. return label
  1004. Example of usage with a custom scene instance:
  1005. ::
  1006. func _make_custom_tooltip(for_text):
  1007. var tooltip = preload("res://SomeTooltipScene.tscn").instance()
  1008. tooltip.get_node("Label").text = for_text
  1009. return tooltip
  1010. .. rst-class:: classref-item-separator
  1011. ----
  1012. .. _class_Control_method_accept_event:
  1013. .. rst-class:: classref-method
  1014. void **accept_event** **(** **)**
  1015. Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to :ref:`Node._unhandled_input<class_Node_method__unhandled_input>` or :ref:`Node._unhandled_key_input<class_Node_method__unhandled_key_input>`.
  1016. .. rst-class:: classref-item-separator
  1017. ----
  1018. .. _class_Control_method_add_color_override:
  1019. .. rst-class:: classref-method
  1020. void **add_color_override** **(** :ref:`String<class_String>` name, :ref:`Color<class_Color>` color **)**
  1021. Creates a local override for a theme :ref:`Color<class_Color>` with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1022. See also :ref:`get_color<class_Control_method_get_color>`, :ref:`remove_color_override<class_Control_method_remove_color_override>`.
  1023. \ **Example of overriding a label's color and resetting it later:**\
  1024. ::
  1025. # Given the child Label node "MyLabel", override its font color with a custom value.
  1026. $MyLabel.add_color_override("font_color", Color(1, 0.5, 0))
  1027. # Reset the font color of the child label.
  1028. $MyLabel.add_color_override("font_color", get_color("font_color", "Label"))
  1029. .. rst-class:: classref-item-separator
  1030. ----
  1031. .. _class_Control_method_add_constant_override:
  1032. .. rst-class:: classref-method
  1033. void **add_constant_override** **(** :ref:`String<class_String>` name, :ref:`int<class_int>` constant **)**
  1034. Creates a local override for a theme constant with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1035. See also :ref:`get_constant<class_Control_method_get_constant>`, :ref:`remove_constant_override<class_Control_method_remove_constant_override>`.
  1036. .. rst-class:: classref-item-separator
  1037. ----
  1038. .. _class_Control_method_add_font_override:
  1039. .. rst-class:: classref-method
  1040. void **add_font_override** **(** :ref:`String<class_String>` name, :ref:`Font<class_Font>` font **)**
  1041. Creates a local override for a theme :ref:`Font<class_Font>` with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1042. \ **Note:** An override can be removed by assigning it a ``null`` value. This behavior is deprecated and will be removed in 4.0, use :ref:`remove_font_override<class_Control_method_remove_font_override>` instead.
  1043. See also :ref:`get_font<class_Control_method_get_font>`.
  1044. .. rst-class:: classref-item-separator
  1045. ----
  1046. .. _class_Control_method_add_icon_override:
  1047. .. rst-class:: classref-method
  1048. void **add_icon_override** **(** :ref:`String<class_String>` name, :ref:`Texture<class_Texture>` texture **)**
  1049. Creates a local override for a theme icon with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1050. \ **Note:** An override can be removed by assigning it a ``null`` value. This behavior is deprecated and will be removed in 4.0, use :ref:`remove_icon_override<class_Control_method_remove_icon_override>` instead.
  1051. See also :ref:`get_icon<class_Control_method_get_icon>`.
  1052. .. rst-class:: classref-item-separator
  1053. ----
  1054. .. _class_Control_method_add_shader_override:
  1055. .. rst-class:: classref-method
  1056. void **add_shader_override** **(** :ref:`String<class_String>` name, :ref:`Shader<class_Shader>` shader **)**
  1057. Creates a local override for a theme shader with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1058. \ **Note:** An override can be removed by assigning it a ``null`` value. This behavior is deprecated and will be removed in 4.0, use :ref:`remove_shader_override<class_Control_method_remove_shader_override>` instead.
  1059. .. rst-class:: classref-item-separator
  1060. ----
  1061. .. _class_Control_method_add_stylebox_override:
  1062. .. rst-class:: classref-method
  1063. void **add_stylebox_override** **(** :ref:`String<class_String>` name, :ref:`StyleBox<class_StyleBox>` stylebox **)**
  1064. Creates a local override for a theme :ref:`StyleBox<class_StyleBox>` with the specified ``name``. Local overrides always take precedence when fetching theme items for the control.
  1065. \ **Note:** An override can be removed by assigning it a ``null`` value. This behavior is deprecated and will be removed in 4.0, use :ref:`remove_stylebox_override<class_Control_method_remove_stylebox_override>` instead.
  1066. See also :ref:`get_stylebox<class_Control_method_get_stylebox>`.
  1067. \ **Example of modifying a property in a StyleBox by duplicating it:**\
  1068. ::
  1069. # The snippet below assumes the child node MyButton has a StyleBoxFlat assigned.
  1070. # Resources are shared across instances, so we need to duplicate it
  1071. # to avoid modifying the appearance of all other buttons.
  1072. var new_stylebox_normal = $MyButton.get_stylebox("normal").duplicate()
  1073. new_stylebox_normal.border_width_top = 3
  1074. new_stylebox_normal.border_color = Color(0, 1, 0.5)
  1075. $MyButton.add_stylebox_override("normal", new_stylebox_normal)
  1076. # Remove the stylebox override.
  1077. $MyButton.add_stylebox_override("normal", null)
  1078. .. rst-class:: classref-item-separator
  1079. ----
  1080. .. _class_Control_method_can_drop_data:
  1081. .. rst-class:: classref-method
  1082. :ref:`bool<class_bool>` **can_drop_data** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data **)** |virtual|
  1083. Godot calls this method to test if ``data`` from a control's :ref:`get_drag_data<class_Control_method_get_drag_data>` can be dropped at ``position``. ``position`` is local to this control.
  1084. This method should only be used to test the data. Process the data in :ref:`drop_data<class_Control_method_drop_data>`.
  1085. ::
  1086. func can_drop_data(position, data):
  1087. # Check position if it is relevant to you
  1088. # Otherwise, just check data
  1089. return typeof(data) == TYPE_DICTIONARY and data.has("expected")
  1090. .. rst-class:: classref-item-separator
  1091. ----
  1092. .. _class_Control_method_drop_data:
  1093. .. rst-class:: classref-method
  1094. void **drop_data** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data **)** |virtual|
  1095. Godot calls this method to pass you the ``data`` from a control's :ref:`get_drag_data<class_Control_method_get_drag_data>` result. Godot first calls :ref:`can_drop_data<class_Control_method_can_drop_data>` to test if ``data`` is allowed to drop at ``position`` where ``position`` is local to this control.
  1096. ::
  1097. func can_drop_data(position, data):
  1098. return typeof(data) == TYPE_DICTIONARY and data.has("color")
  1099. func drop_data(position, data):
  1100. color = data["color"]
  1101. .. rst-class:: classref-item-separator
  1102. ----
  1103. .. _class_Control_method_find_next_valid_focus:
  1104. .. rst-class:: classref-method
  1105. :ref:`Control<class_Control>` **find_next_valid_focus** **(** **)** |const|
  1106. Finds the next (below in the tree) **Control** that can receive the focus.
  1107. .. rst-class:: classref-item-separator
  1108. ----
  1109. .. _class_Control_method_find_prev_valid_focus:
  1110. .. rst-class:: classref-method
  1111. :ref:`Control<class_Control>` **find_prev_valid_focus** **(** **)** |const|
  1112. Finds the previous (above in the tree) **Control** that can receive the focus.
  1113. .. rst-class:: classref-item-separator
  1114. ----
  1115. .. _class_Control_method_force_drag:
  1116. .. rst-class:: classref-method
  1117. void **force_drag** **(** :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` preview **)**
  1118. Forces drag and bypasses :ref:`get_drag_data<class_Control_method_get_drag_data>` and :ref:`set_drag_preview<class_Control_method_set_drag_preview>` by passing ``data`` and ``preview``. Drag will start even if the mouse is neither over nor pressed on this control.
  1119. The methods :ref:`can_drop_data<class_Control_method_can_drop_data>` and :ref:`drop_data<class_Control_method_drop_data>` must be implemented on controls that want to receive drop data.
  1120. .. rst-class:: classref-item-separator
  1121. ----
  1122. .. _class_Control_method_get_anchor:
  1123. .. rst-class:: classref-method
  1124. :ref:`float<class_float>` **get_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  1125. Returns the anchor identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum. A getter method for :ref:`anchor_bottom<class_Control_property_anchor_bottom>`, :ref:`anchor_left<class_Control_property_anchor_left>`, :ref:`anchor_right<class_Control_property_anchor_right>` and :ref:`anchor_top<class_Control_property_anchor_top>`.
  1126. .. rst-class:: classref-item-separator
  1127. ----
  1128. .. _class_Control_method_get_begin:
  1129. .. rst-class:: classref-method
  1130. :ref:`Vector2<class_Vector2>` **get_begin** **(** **)** |const|
  1131. Returns :ref:`margin_left<class_Control_property_margin_left>` and :ref:`margin_top<class_Control_property_margin_top>`. See also :ref:`rect_position<class_Control_property_rect_position>`.
  1132. .. rst-class:: classref-item-separator
  1133. ----
  1134. .. _class_Control_method_get_color:
  1135. .. rst-class:: classref-method
  1136. :ref:`Color<class_Color>` **get_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1137. Returns a :ref:`Color<class_Color>` from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has a color item with the specified ``name`` and ``theme_type``. If ``theme_type`` is omitted the class name of the current control is used as the type, or :ref:`theme_type_variation<class_Control_property_theme_type_variation>` if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance.
  1138. For the current control its local overrides are considered first (see :ref:`add_color_override<class_Control_method_add_color_override>`), then its assigned :ref:`theme<class_Control_property_theme>`. After the current control, each parent control and its assigned :ref:`theme<class_Control_property_theme>` are considered; controls without a :ref:`theme<class_Control_property_theme>` assigned are skipped. If no matching :ref:`Theme<class_Theme>` is found in the tree, a custom project :ref:`Theme<class_Theme>` (see :ref:`ProjectSettings.gui/theme/custom<class_ProjectSettings_property_gui/theme/custom>`) and the default :ref:`Theme<class_Theme>` are used.
  1139. ::
  1140. func _ready():
  1141. # Get the font color defined for the current Control's class, if it exists.
  1142. modulate = get_color("font_color")
  1143. # Get the font color defined for the Button class.
  1144. modulate = get_color("font_color", "Button")
  1145. .. rst-class:: classref-item-separator
  1146. ----
  1147. .. _class_Control_method_get_combined_minimum_size:
  1148. .. rst-class:: classref-method
  1149. :ref:`Vector2<class_Vector2>` **get_combined_minimum_size** **(** **)** |const|
  1150. Returns combined minimum size from :ref:`rect_min_size<class_Control_property_rect_min_size>` and :ref:`get_minimum_size<class_Control_method_get_minimum_size>`.
  1151. .. rst-class:: classref-item-separator
  1152. ----
  1153. .. _class_Control_method_get_constant:
  1154. .. rst-class:: classref-method
  1155. :ref:`int<class_int>` **get_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1156. Returns a constant from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has a constant item with the specified ``name`` and ``theme_type``.
  1157. See :ref:`get_color<class_Control_method_get_color>` for details.
  1158. .. rst-class:: classref-item-separator
  1159. ----
  1160. .. _class_Control_method_get_cursor_shape:
  1161. .. rst-class:: classref-method
  1162. :ref:`CursorShape<enum_Control_CursorShape>` **get_cursor_shape** **(** :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)** |const|
  1163. Returns the mouse cursor shape the control displays on mouse hover. See :ref:`CursorShape<enum_Control_CursorShape>`.
  1164. .. rst-class:: classref-item-separator
  1165. ----
  1166. .. _class_Control_method_get_drag_data:
  1167. .. rst-class:: classref-method
  1168. :ref:`Variant<class_Variant>` **get_drag_data** **(** :ref:`Vector2<class_Vector2>` position **)** |virtual|
  1169. 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 :ref:`can_drop_data<class_Control_method_can_drop_data>` and :ref:`drop_data<class_Control_method_drop_data>`. ``position`` is local to this control. Drag may be forced with :ref:`force_drag<class_Control_method_force_drag>`.
  1170. A preview that will follow the mouse that should represent the data can be set with :ref:`set_drag_preview<class_Control_method_set_drag_preview>`. A good time to set the preview is in this method.
  1171. ::
  1172. func get_drag_data(position):
  1173. var mydata = make_data()
  1174. set_drag_preview(make_preview(mydata))
  1175. return mydata
  1176. .. rst-class:: classref-item-separator
  1177. ----
  1178. .. _class_Control_method_get_end:
  1179. .. rst-class:: classref-method
  1180. :ref:`Vector2<class_Vector2>` **get_end** **(** **)** |const|
  1181. Returns :ref:`margin_right<class_Control_property_margin_right>` and :ref:`margin_bottom<class_Control_property_margin_bottom>`.
  1182. .. rst-class:: classref-item-separator
  1183. ----
  1184. .. _class_Control_method_get_focus_neighbour:
  1185. .. rst-class:: classref-method
  1186. :ref:`NodePath<class_NodePath>` **get_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  1187. Returns the focus neighbour identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum. A getter method for :ref:`focus_neighbour_bottom<class_Control_property_focus_neighbour_bottom>`, :ref:`focus_neighbour_left<class_Control_property_focus_neighbour_left>`, :ref:`focus_neighbour_right<class_Control_property_focus_neighbour_right>` and :ref:`focus_neighbour_top<class_Control_property_focus_neighbour_top>`.
  1188. .. rst-class:: classref-item-separator
  1189. ----
  1190. .. _class_Control_method_get_focus_owner:
  1191. .. rst-class:: classref-method
  1192. :ref:`Control<class_Control>` **get_focus_owner** **(** **)** |const|
  1193. Returns the control that has focus or ``null`` if none.
  1194. .. rst-class:: classref-item-separator
  1195. ----
  1196. .. _class_Control_method_get_font:
  1197. .. rst-class:: classref-method
  1198. :ref:`Font<class_Font>` **get_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1199. Returns a :ref:`Font<class_Font>` from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has a font item with the specified ``name`` and ``theme_type``.
  1200. See :ref:`get_color<class_Control_method_get_color>` for details.
  1201. .. rst-class:: classref-item-separator
  1202. ----
  1203. .. _class_Control_method_get_global_rect:
  1204. .. rst-class:: classref-method
  1205. :ref:`Rect2<class_Rect2>` **get_global_rect** **(** **)** |const|
  1206. Returns the position and size of the control relative to the top-left corner of the screen. See :ref:`rect_position<class_Control_property_rect_position>` and :ref:`rect_size<class_Control_property_rect_size>`.
  1207. .. rst-class:: classref-item-separator
  1208. ----
  1209. .. _class_Control_method_get_icon:
  1210. .. rst-class:: classref-method
  1211. :ref:`Texture<class_Texture>` **get_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1212. Returns an icon from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has an icon item with the specified ``name`` and ``theme_type``.
  1213. See :ref:`get_color<class_Control_method_get_color>` for details.
  1214. .. rst-class:: classref-item-separator
  1215. ----
  1216. .. _class_Control_method_get_margin:
  1217. .. rst-class:: classref-method
  1218. :ref:`float<class_float>` **get_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  1219. Returns the anchor identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum. A getter method for :ref:`margin_bottom<class_Control_property_margin_bottom>`, :ref:`margin_left<class_Control_property_margin_left>`, :ref:`margin_right<class_Control_property_margin_right>` and :ref:`margin_top<class_Control_property_margin_top>`.
  1220. .. rst-class:: classref-item-separator
  1221. ----
  1222. .. _class_Control_method_get_minimum_size:
  1223. .. rst-class:: classref-method
  1224. :ref:`Vector2<class_Vector2>` **get_minimum_size** **(** **)** |const|
  1225. Returns the minimum size for this control. See :ref:`rect_min_size<class_Control_property_rect_min_size>`.
  1226. .. rst-class:: classref-item-separator
  1227. ----
  1228. .. _class_Control_method_get_parent_area_size:
  1229. .. rst-class:: classref-method
  1230. :ref:`Vector2<class_Vector2>` **get_parent_area_size** **(** **)** |const|
  1231. Returns the width/height occupied in the parent control.
  1232. .. rst-class:: classref-item-separator
  1233. ----
  1234. .. _class_Control_method_get_parent_control:
  1235. .. rst-class:: classref-method
  1236. :ref:`Control<class_Control>` **get_parent_control** **(** **)** |const|
  1237. Returns the parent control node.
  1238. .. rst-class:: classref-item-separator
  1239. ----
  1240. .. _class_Control_method_get_rect:
  1241. .. rst-class:: classref-method
  1242. :ref:`Rect2<class_Rect2>` **get_rect** **(** **)** |const|
  1243. Returns the position and size of the control relative to the top-left corner of the parent Control. See :ref:`rect_position<class_Control_property_rect_position>` and :ref:`rect_size<class_Control_property_rect_size>`.
  1244. .. rst-class:: classref-item-separator
  1245. ----
  1246. .. _class_Control_method_get_rotation:
  1247. .. rst-class:: classref-method
  1248. :ref:`float<class_float>` **get_rotation** **(** **)** |const|
  1249. Returns the rotation (in radians).
  1250. .. rst-class:: classref-item-separator
  1251. ----
  1252. .. _class_Control_method_get_stylebox:
  1253. .. rst-class:: classref-method
  1254. :ref:`StyleBox<class_StyleBox>` **get_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1255. Returns a :ref:`StyleBox<class_StyleBox>` from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has a stylebox item with the specified ``name`` and ``theme_type``.
  1256. See :ref:`get_color<class_Control_method_get_color>` for details.
  1257. .. rst-class:: classref-item-separator
  1258. ----
  1259. .. _class_Control_method_get_theme_default_font:
  1260. .. rst-class:: classref-method
  1261. :ref:`Font<class_Font>` **get_theme_default_font** **(** **)** |const|
  1262. Returns the default font from the first matching :ref:`Theme<class_Theme>` in the tree if that :ref:`Theme<class_Theme>` has a valid :ref:`Theme.default_font<class_Theme_property_default_font>` value.
  1263. See :ref:`get_color<class_Control_method_get_color>` for details.
  1264. .. rst-class:: classref-item-separator
  1265. ----
  1266. .. _class_Control_method_get_tooltip:
  1267. .. rst-class:: classref-method
  1268. :ref:`String<class_String>` **get_tooltip** **(** :ref:`Vector2<class_Vector2>` at_position=Vector2( 0, 0 ) **)** |const|
  1269. Returns the tooltip, which will appear when the cursor is resting over this control. See :ref:`hint_tooltip<class_Control_property_hint_tooltip>`.
  1270. .. rst-class:: classref-item-separator
  1271. ----
  1272. .. _class_Control_method_grab_click_focus:
  1273. .. rst-class:: classref-method
  1274. void **grab_click_focus** **(** **)**
  1275. Creates an :ref:`InputEventMouseButton<class_InputEventMouseButton>` that attempts to click the control. If the event is received, the control acquires focus.
  1276. ::
  1277. func _process(delta):
  1278. grab_click_focus() #when clicking another Control node, this node will be clicked instead
  1279. .. rst-class:: classref-item-separator
  1280. ----
  1281. .. _class_Control_method_grab_focus:
  1282. .. rst-class:: classref-method
  1283. void **grab_focus** **(** **)**
  1284. Steal the focus from another control and become the focused control (see :ref:`focus_mode<class_Control_property_focus_mode>`).
  1285. \ **Note**: Using this method together with :ref:`Object.call_deferred<class_Object_method_call_deferred>` makes it more reliable, especially when called inside :ref:`Node._ready<class_Node_method__ready>`.
  1286. .. rst-class:: classref-item-separator
  1287. ----
  1288. .. _class_Control_method_has_color:
  1289. .. rst-class:: classref-method
  1290. :ref:`bool<class_bool>` **has_color** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1291. Returns ``true`` if there is a matching :ref:`Theme<class_Theme>` in the tree that has a color item with the specified ``name`` and ``theme_type``.
  1292. See :ref:`get_color<class_Control_method_get_color>` for details.
  1293. .. rst-class:: classref-item-separator
  1294. ----
  1295. .. _class_Control_method_has_color_override:
  1296. .. rst-class:: classref-method
  1297. :ref:`bool<class_bool>` **has_color_override** **(** :ref:`String<class_String>` name **)** |const|
  1298. Returns ``true`` if there is a local override for a theme :ref:`Color<class_Color>` with the specified ``name`` in this **Control** node.
  1299. See :ref:`add_color_override<class_Control_method_add_color_override>`.
  1300. .. rst-class:: classref-item-separator
  1301. ----
  1302. .. _class_Control_method_has_constant:
  1303. .. rst-class:: classref-method
  1304. :ref:`bool<class_bool>` **has_constant** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1305. Returns ``true`` if there is a matching :ref:`Theme<class_Theme>` in the tree that has a constant item with the specified ``name`` and ``theme_type``.
  1306. See :ref:`get_color<class_Control_method_get_color>` for details.
  1307. .. rst-class:: classref-item-separator
  1308. ----
  1309. .. _class_Control_method_has_constant_override:
  1310. .. rst-class:: classref-method
  1311. :ref:`bool<class_bool>` **has_constant_override** **(** :ref:`String<class_String>` name **)** |const|
  1312. Returns ``true`` if there is a local override for a theme constant with the specified ``name`` in this **Control** node.
  1313. See :ref:`add_constant_override<class_Control_method_add_constant_override>`.
  1314. .. rst-class:: classref-item-separator
  1315. ----
  1316. .. _class_Control_method_has_focus:
  1317. .. rst-class:: classref-method
  1318. :ref:`bool<class_bool>` **has_focus** **(** **)** |const|
  1319. Returns ``true`` if this is the current focused control. See :ref:`focus_mode<class_Control_property_focus_mode>`.
  1320. .. rst-class:: classref-item-separator
  1321. ----
  1322. .. _class_Control_method_has_font:
  1323. .. rst-class:: classref-method
  1324. :ref:`bool<class_bool>` **has_font** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1325. Returns ``true`` if there is a matching :ref:`Theme<class_Theme>` in the tree that has a font item with the specified ``name`` and ``theme_type``.
  1326. See :ref:`get_color<class_Control_method_get_color>` for details.
  1327. .. rst-class:: classref-item-separator
  1328. ----
  1329. .. _class_Control_method_has_font_override:
  1330. .. rst-class:: classref-method
  1331. :ref:`bool<class_bool>` **has_font_override** **(** :ref:`String<class_String>` name **)** |const|
  1332. Returns ``true`` if there is a local override for a theme :ref:`Font<class_Font>` with the specified ``name`` in this **Control** node.
  1333. See :ref:`add_font_override<class_Control_method_add_font_override>`.
  1334. .. rst-class:: classref-item-separator
  1335. ----
  1336. .. _class_Control_method_has_icon:
  1337. .. rst-class:: classref-method
  1338. :ref:`bool<class_bool>` **has_icon** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1339. Returns ``true`` if there is a matching :ref:`Theme<class_Theme>` in the tree that has an icon item with the specified ``name`` and ``theme_type``.
  1340. See :ref:`get_color<class_Control_method_get_color>` for details.
  1341. .. rst-class:: classref-item-separator
  1342. ----
  1343. .. _class_Control_method_has_icon_override:
  1344. .. rst-class:: classref-method
  1345. :ref:`bool<class_bool>` **has_icon_override** **(** :ref:`String<class_String>` name **)** |const|
  1346. Returns ``true`` if there is a local override for a theme icon with the specified ``name`` in this **Control** node.
  1347. See :ref:`add_icon_override<class_Control_method_add_icon_override>`.
  1348. .. rst-class:: classref-item-separator
  1349. ----
  1350. .. _class_Control_method_has_point:
  1351. .. rst-class:: classref-method
  1352. :ref:`bool<class_bool>` **has_point** **(** :ref:`Vector2<class_Vector2>` point **)** |virtual|
  1353. Virtual method to be implemented by the user. Returns whether the given ``point`` is inside this control.
  1354. If not overridden, default behavior is checking if the point is within control's Rect.
  1355. \ **Note:** If you want to check if a point is inside the control, you can use ``get_rect().has_point(point)``.
  1356. .. rst-class:: classref-item-separator
  1357. ----
  1358. .. _class_Control_method_has_shader_override:
  1359. .. rst-class:: classref-method
  1360. :ref:`bool<class_bool>` **has_shader_override** **(** :ref:`String<class_String>` name **)** |const|
  1361. Returns ``true`` if there is a local override for a theme shader with the specified ``name`` in this **Control** node.
  1362. See :ref:`add_shader_override<class_Control_method_add_shader_override>`.
  1363. .. rst-class:: classref-item-separator
  1364. ----
  1365. .. _class_Control_method_has_stylebox:
  1366. .. rst-class:: classref-method
  1367. :ref:`bool<class_bool>` **has_stylebox** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` theme_type="" **)** |const|
  1368. Returns ``true`` if there is a matching :ref:`Theme<class_Theme>` in the tree that has a stylebox item with the specified ``name`` and ``theme_type``.
  1369. See :ref:`get_color<class_Control_method_get_color>` for details.
  1370. .. rst-class:: classref-item-separator
  1371. ----
  1372. .. _class_Control_method_has_stylebox_override:
  1373. .. rst-class:: classref-method
  1374. :ref:`bool<class_bool>` **has_stylebox_override** **(** :ref:`String<class_String>` name **)** |const|
  1375. Returns ``true`` if there is a local override for a theme :ref:`StyleBox<class_StyleBox>` with the specified ``name`` in this **Control** node.
  1376. See :ref:`add_stylebox_override<class_Control_method_add_stylebox_override>`.
  1377. .. rst-class:: classref-item-separator
  1378. ----
  1379. .. _class_Control_method_is_drag_successful:
  1380. .. rst-class:: classref-method
  1381. :ref:`bool<class_bool>` **is_drag_successful** **(** **)** |const|
  1382. Returns ``true`` if a drag operation is successful. Alternative to :ref:`Viewport.gui_is_drag_successful<class_Viewport_method_gui_is_drag_successful>`.
  1383. Best used with :ref:`Node.NOTIFICATION_DRAG_END<class_Node_constant_NOTIFICATION_DRAG_END>`.
  1384. .. rst-class:: classref-item-separator
  1385. ----
  1386. .. _class_Control_method_minimum_size_changed:
  1387. .. rst-class:: classref-method
  1388. void **minimum_size_changed** **(** **)**
  1389. Invalidates the size cache in this node and in parent nodes up to toplevel. Intended to be used with :ref:`get_minimum_size<class_Control_method_get_minimum_size>` when the return value is changed. Setting :ref:`rect_min_size<class_Control_property_rect_min_size>` directly calls this method automatically.
  1390. .. rst-class:: classref-item-separator
  1391. ----
  1392. .. _class_Control_method_release_focus:
  1393. .. rst-class:: classref-method
  1394. void **release_focus** **(** **)**
  1395. Give up the focus. No other control will be able to receive keyboard or gamepad input.
  1396. .. rst-class:: classref-item-separator
  1397. ----
  1398. .. _class_Control_method_remove_color_override:
  1399. .. rst-class:: classref-method
  1400. void **remove_color_override** **(** :ref:`String<class_String>` name **)**
  1401. Removes a theme override for a :ref:`Color<class_Color>` with the given ``name``.
  1402. .. rst-class:: classref-item-separator
  1403. ----
  1404. .. _class_Control_method_remove_constant_override:
  1405. .. rst-class:: classref-method
  1406. void **remove_constant_override** **(** :ref:`String<class_String>` name **)**
  1407. Removes a theme override for a constant with the given ``name``.
  1408. .. rst-class:: classref-item-separator
  1409. ----
  1410. .. _class_Control_method_remove_font_override:
  1411. .. rst-class:: classref-method
  1412. void **remove_font_override** **(** :ref:`String<class_String>` name **)**
  1413. Removes a theme override for a :ref:`Font<class_Font>` with the given ``name``.
  1414. .. rst-class:: classref-item-separator
  1415. ----
  1416. .. _class_Control_method_remove_icon_override:
  1417. .. rst-class:: classref-method
  1418. void **remove_icon_override** **(** :ref:`String<class_String>` name **)**
  1419. Removes a theme override for an icon with the given ``name``.
  1420. .. rst-class:: classref-item-separator
  1421. ----
  1422. .. _class_Control_method_remove_shader_override:
  1423. .. rst-class:: classref-method
  1424. void **remove_shader_override** **(** :ref:`String<class_String>` name **)**
  1425. Removes a theme override for a shader with the given ``name``.
  1426. .. rst-class:: classref-item-separator
  1427. ----
  1428. .. _class_Control_method_remove_stylebox_override:
  1429. .. rst-class:: classref-method
  1430. void **remove_stylebox_override** **(** :ref:`String<class_String>` name **)**
  1431. Removes a theme override for a :ref:`StyleBox<class_StyleBox>` with the given ``name``.
  1432. .. rst-class:: classref-item-separator
  1433. ----
  1434. .. _class_Control_method_set_anchor:
  1435. .. rst-class:: classref-method
  1436. void **set_anchor** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` anchor, :ref:`bool<class_bool>` keep_margin=false, :ref:`bool<class_bool>` push_opposite_anchor=true **)**
  1437. Sets the anchor identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum to value ``anchor``. A setter method for :ref:`anchor_bottom<class_Control_property_anchor_bottom>`, :ref:`anchor_left<class_Control_property_anchor_left>`, :ref:`anchor_right<class_Control_property_anchor_right>` and :ref:`anchor_top<class_Control_property_anchor_top>`.
  1438. If ``keep_margin`` is ``true``, margins aren't updated after this operation.
  1439. 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.
  1440. .. rst-class:: classref-item-separator
  1441. ----
  1442. .. _class_Control_method_set_anchor_and_margin:
  1443. .. rst-class:: classref-method
  1444. void **set_anchor_and_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` anchor, :ref:`float<class_float>` offset, :ref:`bool<class_bool>` push_opposite_anchor=false **)**
  1445. Works the same as :ref:`set_anchor<class_Control_method_set_anchor>`, but instead of ``keep_margin`` argument and automatic update of margin, it allows to set the margin offset yourself (see :ref:`set_margin<class_Control_method_set_margin>`).
  1446. .. rst-class:: classref-item-separator
  1447. ----
  1448. .. _class_Control_method_set_anchors_and_margins_preset:
  1449. .. rst-class:: classref-method
  1450. void **set_anchors_and_margins_preset** **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` resize_mode=0, :ref:`int<class_int>` margin=0 **)**
  1451. Sets both anchor preset and margin preset. See :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` and :ref:`set_margins_preset<class_Control_method_set_margins_preset>`.
  1452. .. rst-class:: classref-item-separator
  1453. ----
  1454. .. _class_Control_method_set_anchors_preset:
  1455. .. rst-class:: classref-method
  1456. void **set_anchors_preset** **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`bool<class_bool>` keep_margins=false **)**
  1457. Sets the anchors to a ``preset`` from :ref:`LayoutPreset<enum_Control_LayoutPreset>` enum. This is the code equivalent to using the Layout menu in the 2D editor.
  1458. If ``keep_margins`` is ``true``, control's position will also be updated.
  1459. .. rst-class:: classref-item-separator
  1460. ----
  1461. .. _class_Control_method_set_begin:
  1462. .. rst-class:: classref-method
  1463. void **set_begin** **(** :ref:`Vector2<class_Vector2>` position **)**
  1464. Sets :ref:`margin_left<class_Control_property_margin_left>` and :ref:`margin_top<class_Control_property_margin_top>` at the same time. Equivalent of changing :ref:`rect_position<class_Control_property_rect_position>`.
  1465. .. rst-class:: classref-item-separator
  1466. ----
  1467. .. _class_Control_method_set_drag_forwarding:
  1468. .. rst-class:: classref-method
  1469. void **set_drag_forwarding** **(** :ref:`Control<class_Control>` target **)**
  1470. Forwards the handling of this control's drag and drop to ``target`` control.
  1471. Forwarding can be implemented in the target control similar to the methods :ref:`get_drag_data<class_Control_method_get_drag_data>`, :ref:`can_drop_data<class_Control_method_can_drop_data>`, and :ref:`drop_data<class_Control_method_drop_data>` but with two differences:
  1472. 1. The function name must be suffixed with **_fw**\
  1473. 2. The function must take an extra argument that is the control doing the forwarding
  1474. ::
  1475. # ThisControl.gd
  1476. extends Control
  1477. func _ready():
  1478. set_drag_forwarding(target_control)
  1479. # TargetControl.gd
  1480. extends Control
  1481. func can_drop_data_fw(position, data, from_control):
  1482. return true
  1483. func drop_data_fw(position, data, from_control):
  1484. my_handle_data(data)
  1485. func get_drag_data_fw(position, from_control):
  1486. set_drag_preview(my_preview)
  1487. return my_data()
  1488. .. rst-class:: classref-item-separator
  1489. ----
  1490. .. _class_Control_method_set_drag_preview:
  1491. .. rst-class:: classref-method
  1492. void **set_drag_preview** **(** :ref:`Control<class_Control>` control **)**
  1493. Shows the given control at the mouse pointer. A good time to call this method is in :ref:`get_drag_data<class_Control_method_get_drag_data>`. 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.
  1494. ::
  1495. export (Color, RGBA) var color = Color(1, 0, 0, 1)
  1496. func get_drag_data(position):
  1497. # Use a control that is not in the tree
  1498. var cpb = ColorPickerButton.new()
  1499. cpb.color = color
  1500. cpb.rect_size = Vector2(50, 50)
  1501. set_drag_preview(cpb)
  1502. return color
  1503. .. rst-class:: classref-item-separator
  1504. ----
  1505. .. _class_Control_method_set_end:
  1506. .. rst-class:: classref-method
  1507. void **set_end** **(** :ref:`Vector2<class_Vector2>` position **)**
  1508. Sets :ref:`margin_right<class_Control_property_margin_right>` and :ref:`margin_bottom<class_Control_property_margin_bottom>` at the same time.
  1509. .. rst-class:: classref-item-separator
  1510. ----
  1511. .. _class_Control_method_set_focus_neighbour:
  1512. .. rst-class:: classref-method
  1513. void **set_focus_neighbour** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`NodePath<class_NodePath>` neighbour **)**
  1514. Sets the anchor identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum to **Control** at ``neighbor`` node path. A setter method for :ref:`focus_neighbour_bottom<class_Control_property_focus_neighbour_bottom>`, :ref:`focus_neighbour_left<class_Control_property_focus_neighbour_left>`, :ref:`focus_neighbour_right<class_Control_property_focus_neighbour_right>` and :ref:`focus_neighbour_top<class_Control_property_focus_neighbour_top>`.
  1515. .. rst-class:: classref-item-separator
  1516. ----
  1517. .. _class_Control_method_set_global_position:
  1518. .. rst-class:: classref-method
  1519. void **set_global_position** **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` keep_margins=false **)**
  1520. Sets the :ref:`rect_global_position<class_Control_property_rect_global_position>` to given ``position``.
  1521. If ``keep_margins`` is ``true``, control's anchors will be updated instead of margins.
  1522. .. rst-class:: classref-item-separator
  1523. ----
  1524. .. _class_Control_method_set_margin:
  1525. .. rst-class:: classref-method
  1526. void **set_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` offset **)**
  1527. Sets the margin identified by ``margin`` constant from :ref:`Margin<enum_@GlobalScope_Margin>` enum to given ``offset``. A setter method for :ref:`margin_bottom<class_Control_property_margin_bottom>`, :ref:`margin_left<class_Control_property_margin_left>`, :ref:`margin_right<class_Control_property_margin_right>` and :ref:`margin_top<class_Control_property_margin_top>`.
  1528. .. rst-class:: classref-item-separator
  1529. ----
  1530. .. _class_Control_method_set_margins_preset:
  1531. .. rst-class:: classref-method
  1532. void **set_margins_preset** **(** :ref:`LayoutPreset<enum_Control_LayoutPreset>` preset, :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` resize_mode=0, :ref:`int<class_int>` margin=0 **)**
  1533. Sets the margins to a ``preset`` from :ref:`LayoutPreset<enum_Control_LayoutPreset>` enum. This is the code equivalent to using the Layout menu in the 2D editor.
  1534. Use parameter ``resize_mode`` with constants from :ref:`LayoutPresetMode<enum_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``.
  1535. Use parameter ``margin`` to determine the gap between the **Control** and the edges.
  1536. .. rst-class:: classref-item-separator
  1537. ----
  1538. .. _class_Control_method_set_position:
  1539. .. rst-class:: classref-method
  1540. void **set_position** **(** :ref:`Vector2<class_Vector2>` position, :ref:`bool<class_bool>` keep_margins=false **)**
  1541. Sets the :ref:`rect_position<class_Control_property_rect_position>` to given ``position``.
  1542. If ``keep_margins`` is ``true``, control's anchors will be updated instead of margins.
  1543. .. rst-class:: classref-item-separator
  1544. ----
  1545. .. _class_Control_method_set_rotation:
  1546. .. rst-class:: classref-method
  1547. void **set_rotation** **(** :ref:`float<class_float>` radians **)**
  1548. Sets the rotation (in radians).
  1549. .. rst-class:: classref-item-separator
  1550. ----
  1551. .. _class_Control_method_set_size:
  1552. .. rst-class:: classref-method
  1553. void **set_size** **(** :ref:`Vector2<class_Vector2>` size, :ref:`bool<class_bool>` keep_margins=false **)**
  1554. Sets the size (see :ref:`rect_size<class_Control_property_rect_size>`).
  1555. If ``keep_margins`` is ``true``, control's anchors will be updated instead of margins.
  1556. .. rst-class:: classref-item-separator
  1557. ----
  1558. .. _class_Control_method_show_modal:
  1559. .. rst-class:: classref-method
  1560. void **show_modal** **(** :ref:`bool<class_bool>` exclusive=false **)**
  1561. 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.
  1562. If ``exclusive`` is ``true``, other controls will not receive input and clicking outside this control will not close it.
  1563. .. rst-class:: classref-item-separator
  1564. ----
  1565. .. _class_Control_method_warp_mouse:
  1566. .. rst-class:: classref-method
  1567. void **warp_mouse** **(** :ref:`Vector2<class_Vector2>` to_position **)**
  1568. Moves the mouse cursor to ``to_position``, relative to :ref:`rect_position<class_Control_property_rect_position>` of this **Control**.
  1569. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  1570. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  1571. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  1572. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`