mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
3385 lines
204 KiB
ReStructuredText
3385 lines
204 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. DO NOT EDIT THIS FILE!!!
|
||
.. Generated automatically from Godot engine sources.
|
||
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
||
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Control.xml.
|
||
|
||
.. _class_Control:
|
||
|
||
Control
|
||
=======
|
||
|
||
**继承:** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||
|
||
**派生:** :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:`MenuBar<class_MenuBar>`, :ref:`NinePatchRect<class_NinePatchRect>`, :ref:`Panel<class_Panel>`, :ref:`Range<class_Range>`, :ref:`ReferenceRect<class_ReferenceRect>`, :ref:`RichTextLabel<class_RichTextLabel>`, :ref:`Separator<class_Separator>`, :ref:`TabBar<class_TabBar>`, :ref:`TextEdit<class_TextEdit>`, :ref:`TextureRect<class_TextureRect>`, :ref:`Tree<class_Tree>`, :ref:`VideoStreamPlayer<class_VideoStreamPlayer>`
|
||
|
||
所有 GUI 控件的基类。根据其父控件调整其位置和大小。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
描述
|
||
----
|
||
|
||
所有 UI 相关节点的基类。\ **Control** 具有定义其范围的边界矩形,相对于父控件或当前视口的锚点位置,以及相对于锚点的偏移。当节点、任何父节点或屏幕尺寸发生变化时,偏移就会自动更新。
|
||
|
||
更多关于 Godot 的 UI 系统、锚点、偏移和容器的信息,请参阅手册中的相关教程。要构建灵活的 UI,你需要混合使用从 **Control** 和 :ref:`Container<class_Container>` 节点继承的 UI 元素。
|
||
|
||
\ **用户界面节点与输入**\
|
||
|
||
Godot 使用视口来传播输入事件。视口负责将 :ref:`InputEvent<class_InputEvent>` 传播给它的子节点。因为 :ref:`SceneTree.root<class_SceneTree_property_root>` 是 :ref:`Window<class_Window>`\ ,所以游戏中的所有 UI 元素都会自动进行传播。
|
||
|
||
输入事件通过调用 :ref:`Node._input<class_Node_private_method__input>` 在 :ref:`SceneTree<class_SceneTree>` 中传播,从根节点传播到所有子节点。对 UI 元素而言,覆盖的最好是 :ref:`_gui_input<class_Control_private_method__gui_input>`\ ,可以过滤掉无关的输入事件,例如它会对 Z 顺序、\ :ref:`mouse_filter<class_Control_property_mouse_filter>`\ 、焦点、事件是否在该控件的边界框内等条件进行检查。
|
||
|
||
请调用 :ref:`accept_event<class_Control_method_accept_event>`\ ,这样其他节点就不会收到该事件。输入被接受后,就会被标记为已处理,\ :ref:`Node._unhandled_input<class_Node_private_method__unhandled_input>` 不会对它进行处理。
|
||
|
||
只能有一个 **Control** 节点处于焦点。只有处于焦点的节点才会接收到事件。要获得焦点,请调用 :ref:`grab_focus<class_Control_method_grab_focus>`\ 。导致 **Control** 节点失去焦点的情况有:其他节点获得了焦点、隐藏了聚焦节点。
|
||
|
||
将 :ref:`mouse_filter<class_Control_property_mouse_filter>` 设置为 :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>` 可以让 **Control** 节点忽略鼠标或触摸事件。如果你在按钮上放了一个图标,就会需要用到。
|
||
|
||
\ :ref:`Theme<class_Theme>` 资源会更改控件的外观。如果你更改了 **Control** 节点上的 :ref:`Theme<class_Theme>`\ ,则会影响其所有子节点。要覆盖某些主题的参数,请调用 ``add_theme_*_override`` 方法,例如 :ref:`add_theme_font_override<class_Control_method_add_theme_font_override>`\ 。你可以使用检查器覆盖主题。
|
||
|
||
\ **注意:**\ 主题项\ *不是* :ref:`Object<class_Object>` 的属性。这意味着你无法使用 :ref:`Object.get<class_Object_method_get>` 和 :ref:`Object.set<class_Object_method_set>` 访问它们的值。请改用这个类的 ``get_theme_*`` 和 ``add_theme_*_override`` 方法。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教程
|
||
----
|
||
|
||
- :doc:`GUI 文档索引 <../tutorials/ui/index>`
|
||
|
||
- :doc:`2D 中的自定义绘图 <../tutorials/2d/custom_drawing_in_2d>`
|
||
|
||
- :doc:`控件节点一览 <../tutorials/ui/control_node_gallery>`
|
||
|
||
- :doc:`多分辨率 <../tutorials/rendering/multiple_resolutions>`
|
||
|
||
- `所有 GUI 演示 <https://github.com/godotengine/godot-demo-projects/tree/master/gui>`__
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
属性
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`anchor_bottom<class_Control_property_anchor_bottom>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`anchor_left<class_Control_property_anchor_left>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`anchor_right<class_Control_property_anchor_right>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`anchor_top<class_Control_property_anchor_top>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`auto_translate<class_Control_property_auto_translate>` | |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`clip_contents<class_Control_property_clip_contents>` | ``false`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>` | ``Vector2(0, 0)`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`FocusMode<enum_Control_FocusMode>` | :ref:`focus_mode<class_Control_property_focus_mode>` | ``0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbor_bottom<class_Control_property_focus_neighbor_bottom>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbor_left<class_Control_property_focus_neighbor_left>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbor_right<class_Control_property_focus_neighbor_right>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_neighbor_top<class_Control_property_focus_neighbor_top>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_next<class_Control_property_focus_next>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`focus_previous<class_Control_property_focus_previous>` | ``NodePath("")`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`global_position<class_Control_property_global_position>` | |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`GrowDirection<enum_Control_GrowDirection>` | :ref:`grow_horizontal<class_Control_property_grow_horizontal>` | ``1`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`GrowDirection<enum_Control_GrowDirection>` | :ref:`grow_vertical<class_Control_property_grow_vertical>` | ``1`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`LayoutDirection<enum_Control_LayoutDirection>` | :ref:`layout_direction<class_Control_property_layout_direction>` | ``0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`localize_numeral_system<class_Control_property_localize_numeral_system>` | ``true`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`CursorShape<enum_Control_CursorShape>` | :ref:`mouse_default_cursor_shape<class_Control_property_mouse_default_cursor_shape>` | ``0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`MouseFilter<enum_Control_MouseFilter>` | :ref:`mouse_filter<class_Control_property_mouse_filter>` | ``0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`mouse_force_pass_scroll_events<class_Control_property_mouse_force_pass_scroll_events>` | ``true`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`offset_bottom<class_Control_property_offset_bottom>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`offset_left<class_Control_property_offset_left>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`offset_right<class_Control_property_offset_right>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`offset_top<class_Control_property_offset_top>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | physics_interpolation_mode | ``2`` (overrides :ref:`Node<class_Node_property_physics_interpolation_mode>`) |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`pivot_offset<class_Control_property_pivot_offset>` | ``Vector2(0, 0)`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`position<class_Control_property_position>` | ``Vector2(0, 0)`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`rotation<class_Control_property_rotation>` | ``0.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`rotation_degrees<class_Control_property_rotation_degrees>` | |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`scale<class_Control_property_scale>` | ``Vector2(1, 1)`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Node<class_Node>` | :ref:`shortcut_context<class_Control_property_shortcut_context>` | |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`size<class_Control_property_size>` | ``Vector2(0, 0)`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] | :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` | ``1`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>` | ``1.0`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] | :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` | ``1`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`Theme<class_Theme>` | :ref:`theme<class_Control_property_theme>` | |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`StringName<class_StringName>` | :ref:`theme_type_variation<class_Control_property_theme_type_variation>` | ``&""`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`tooltip_text<class_Control_property_tooltip_text>` | ``""`` |
|
||
+---------------------------------------------------------------------+----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_can_drop_data<class_Control_private_method__can_drop_data>`\ (\ at_position\: :ref:`Vector2<class_Vector2>`, data\: :ref:`Variant<class_Variant>`\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_drop_data<class_Control_private_method__drop_data>`\ (\ at_position\: :ref:`Vector2<class_Vector2>`, data\: :ref:`Variant<class_Variant>`\ ) |virtual| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Variant<class_Variant>` | :ref:`_get_drag_data<class_Control_private_method__get_drag_data>`\ (\ at_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`_get_minimum_size<class_Control_private_method__get_minimum_size>`\ (\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_tooltip<class_Control_private_method__get_tooltip>`\ (\ at_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`_gui_input<class_Control_private_method__gui_input>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_has_point<class_Control_private_method__has_point>`\ (\ point\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Object<class_Object>` | :ref:`_make_custom_tooltip<class_Control_private_method__make_custom_tooltip>`\ (\ for_text\: :ref:`String<class_String>`\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Array<class_Array>`\[:ref:`Vector3i<class_Vector3i>`\] | :ref:`_structured_text_parser<class_Control_private_method__structured_text_parser>`\ (\ args\: :ref:`Array<class_Array>`, text\: :ref:`String<class_String>`\ ) |virtual| |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`accept_event<class_Control_method_accept_event>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_color_override<class_Control_method_add_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`, color\: :ref:`Color<class_Color>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_constant_override<class_Control_method_add_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`, constant\: :ref:`int<class_int>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_font_override<class_Control_method_add_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`, font\: :ref:`Font<class_Font>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_font_size_override<class_Control_method_add_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`, font_size\: :ref:`int<class_int>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_icon_override<class_Control_method_add_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_theme_stylebox_override<class_Control_method_add_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`, stylebox\: :ref:`StyleBox<class_StyleBox>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`begin_bulk_theme_override<class_Control_method_begin_bulk_theme_override>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`end_bulk_theme_override<class_Control_method_end_bulk_theme_override>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Control<class_Control>` | :ref:`find_next_valid_focus<class_Control_method_find_next_valid_focus>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Control<class_Control>` | :ref:`find_prev_valid_focus<class_Control_method_find_prev_valid_focus>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Control<class_Control>` | :ref:`find_valid_focus_neighbor<class_Control_method_find_valid_focus_neighbor>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`force_drag<class_Control_method_force_drag>`\ (\ data\: :ref:`Variant<class_Variant>`, preview\: :ref:`Control<class_Control>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_anchor<class_Control_method_get_anchor>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_begin<class_Control_method_get_begin>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_combined_minimum_size<class_Control_method_get_combined_minimum_size>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`CursorShape<enum_Control_CursorShape>` | :ref:`get_cursor_shape<class_Control_method_get_cursor_shape>`\ (\ position\: :ref:`Vector2<class_Vector2>` = Vector2(0, 0)\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_end<class_Control_method_get_end>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`get_focus_neighbor<class_Control_method_get_focus_neighbor>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Rect2<class_Rect2>` | :ref:`get_global_rect<class_Control_method_get_global_rect>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_minimum_size<class_Control_method_get_minimum_size>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_offset<class_Control_method_get_offset>`\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_parent_area_size<class_Control_method_get_parent_area_size>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Control<class_Control>` | :ref:`get_parent_control<class_Control_method_get_parent_control>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Rect2<class_Rect2>` | :ref:`get_rect<class_Control_method_get_rect>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Vector2<class_Vector2>` | :ref:`get_screen_position<class_Control_method_get_screen_position>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Color<class_Color>` | :ref:`get_theme_color<class_Control_method_get_theme_color>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_theme_constant<class_Control_method_get_theme_constant>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_theme_default_base_scale<class_Control_method_get_theme_default_base_scale>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Font<class_Font>` | :ref:`get_theme_default_font<class_Control_method_get_theme_default_font>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_theme_default_font_size<class_Control_method_get_theme_default_font_size>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Font<class_Font>` | :ref:`get_theme_font<class_Control_method_get_theme_font>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_theme_font_size<class_Control_method_get_theme_font_size>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Texture2D<class_Texture2D>` | :ref:`get_theme_icon<class_Control_method_get_theme_icon>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`StyleBox<class_StyleBox>` | :ref:`get_theme_stylebox<class_Control_method_get_theme_stylebox>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_tooltip<class_Control_method_get_tooltip>`\ (\ at_position\: :ref:`Vector2<class_Vector2>` = Vector2(0, 0)\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`grab_click_focus<class_Control_method_grab_click_focus>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`grab_focus<class_Control_method_grab_focus>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_focus<class_Control_method_has_focus>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_color<class_Control_method_has_theme_color>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_color_override<class_Control_method_has_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_constant<class_Control_method_has_theme_constant>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_constant_override<class_Control_method_has_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_font<class_Control_method_has_theme_font>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_font_override<class_Control_method_has_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_font_size<class_Control_method_has_theme_font_size>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_font_size_override<class_Control_method_has_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_icon<class_Control_method_has_theme_icon>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_icon_override<class_Control_method_has_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_stylebox<class_Control_method_has_theme_stylebox>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_theme_stylebox_override<class_Control_method_has_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_drag_successful<class_Control_method_is_drag_successful>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`is_layout_rtl<class_Control_method_is_layout_rtl>`\ (\ ) |const| |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`release_focus<class_Control_method_release_focus>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_color_override<class_Control_method_remove_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_constant_override<class_Control_method_remove_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_font_override<class_Control_method_remove_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_font_size_override<class_Control_method_remove_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_icon_override<class_Control_method_remove_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_theme_stylebox_override<class_Control_method_remove_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`reset_size<class_Control_method_reset_size>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_anchor<class_Control_method_set_anchor>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, anchor\: :ref:`float<class_float>`, keep_offset\: :ref:`bool<class_bool>` = false, push_opposite_anchor\: :ref:`bool<class_bool>` = true\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_anchor_and_offset<class_Control_method_set_anchor_and_offset>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, anchor\: :ref:`float<class_float>`, offset\: :ref:`float<class_float>`, push_opposite_anchor\: :ref:`bool<class_bool>` = false\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_anchors_and_offsets_preset<class_Control_method_set_anchors_and_offsets_preset>`\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, resize_mode\: :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` = 0, margin\: :ref:`int<class_int>` = 0\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_begin<class_Control_method_set_begin>`\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_drag_forwarding<class_Control_method_set_drag_forwarding>`\ (\ drag_func\: :ref:`Callable<class_Callable>`, can_drop_func\: :ref:`Callable<class_Callable>`, drop_func\: :ref:`Callable<class_Callable>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_drag_preview<class_Control_method_set_drag_preview>`\ (\ control\: :ref:`Control<class_Control>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_end<class_Control_method_set_end>`\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_focus_neighbor<class_Control_method_set_focus_neighbor>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_global_position<class_Control_method_set_global_position>`\ (\ position\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_offset<class_Control_method_set_offset>`\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_offsets_preset<class_Control_method_set_offsets_preset>`\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, resize_mode\: :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` = 0, margin\: :ref:`int<class_int>` = 0\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_position<class_Control_method_set_position>`\ (\ position\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_size<class_Control_method_set_size>`\ (\ size\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`update_minimum_size<class_Control_method_update_minimum_size>`\ (\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`warp_mouse<class_Control_method_warp_mouse>`\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) |
|
||
+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
信号
|
||
----
|
||
|
||
.. _class_Control_signal_focus_entered:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**focus_entered**\ (\ ) :ref:`🔗<class_Control_signal_focus_entered>`
|
||
|
||
当该节点获得焦点时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_focus_exited:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**focus_exited**\ (\ ) :ref:`🔗<class_Control_signal_focus_exited>`
|
||
|
||
当该节点失去焦点时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_gui_input:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**gui_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_Control_signal_gui_input>`
|
||
|
||
当节点收到 :ref:`InputEvent<class_InputEvent>` 时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_minimum_size_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**minimum_size_changed**\ (\ ) :ref:`🔗<class_Control_signal_minimum_size_changed>`
|
||
|
||
当节点的最小大小更改时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_mouse_entered:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**mouse_entered**\ (\ ) :ref:`🔗<class_Control_signal_mouse_entered>`
|
||
|
||
当鼠标光标进入控件(或任何子控件)的可见区域时发出,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到信号。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_mouse_exited:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**mouse_exited**\ (\ ) :ref:`🔗<class_Control_signal_mouse_exited>`
|
||
|
||
当鼠标光标离开控件(或任何子控件)的可见区域时发出,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到信号。
|
||
|
||
\ **注意:**\ 如果要忽略任何顶部节点,检查鼠标是否真的离开了该区域,可以使用如下代码:
|
||
|
||
::
|
||
|
||
func _on_mouse_exited():
|
||
if not Rect2(Vector2(), size).has_point(get_local_mouse_position()):
|
||
# 未悬停在区域上。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_resized:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**resized**\ (\ ) :ref:`🔗<class_Control_signal_resized>`
|
||
|
||
当控件更改大小时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_size_flags_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**size_flags_changed**\ (\ ) :ref:`🔗<class_Control_signal_size_flags_changed>`
|
||
|
||
当大小标志之一更改时发出。见 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_signal_theme_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**theme_changed**\ (\ ) :ref:`🔗<class_Control_signal_theme_changed>`
|
||
|
||
发送 :ref:`NOTIFICATION_THEME_CHANGED<class_Control_constant_NOTIFICATION_THEME_CHANGED>` 通知时发出。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
枚举
|
||
----
|
||
|
||
.. _enum_Control_FocusMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **FocusMode**: :ref:`🔗<enum_Control_FocusMode>`
|
||
|
||
.. _class_Control_constant_FOCUS_NONE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_NONE** = ``0``
|
||
|
||
该节点无法获取焦点。在 :ref:`focus_mode<class_Control_property_focus_mode>` 中使用。
|
||
|
||
.. _class_Control_constant_FOCUS_CLICK:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_CLICK** = ``1``
|
||
|
||
该节点只能通过鼠标点击获取焦点。在 :ref:`focus_mode<class_Control_property_focus_mode>` 中使用。
|
||
|
||
.. _class_Control_constant_FOCUS_ALL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`FocusMode<enum_Control_FocusMode>` **FOCUS_ALL** = ``2``
|
||
|
||
该节点可以通过鼠标单击、使用键盘上的箭头和 Tab 键或使用游戏手柄上的方向键来获取焦点。用于 :ref:`focus_mode<class_Control_property_focus_mode>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_CursorShape:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **CursorShape**: :ref:`🔗<enum_Control_CursorShape>`
|
||
|
||
.. _class_Control_constant_CURSOR_ARROW:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_ARROW** = ``0``
|
||
|
||
当用户将节点悬停时,显示系统的箭头鼠标光标。与 :ref:`mouse_default_cursor_shape<class_Control_property_mouse_default_cursor_shape>` 成员一起使用。
|
||
|
||
.. _class_Control_constant_CURSOR_IBEAM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_IBEAM** = ``1``
|
||
|
||
当用户将节点悬停时,显示系统的 I 型光束鼠标光标。工字梁指针的形状类似于“I”。它告诉用户他们可以突出显示或插入文本。
|
||
|
||
.. _class_Control_constant_CURSOR_POINTING_HAND:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_POINTING_HAND** = ``2``
|
||
|
||
当用户将节点悬停时,显示系统的手形鼠标光标。
|
||
|
||
.. _class_Control_constant_CURSOR_CROSS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_CROSS** = ``3``
|
||
|
||
当用户将鼠标悬停在节点上时,显示系统的交叉鼠标光标。
|
||
|
||
.. _class_Control_constant_CURSOR_WAIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_WAIT** = ``4``
|
||
|
||
当用户悬停节点时,显示系统等待的鼠标光标。通常是一个沙漏。
|
||
|
||
.. _class_Control_constant_CURSOR_BUSY:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_BUSY** = ``5``
|
||
|
||
当用户悬停节点时,显示系统繁忙的鼠标光标。通常是箭头加一个小沙漏。
|
||
|
||
.. _class_Control_constant_CURSOR_DRAG:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_DRAG** = ``6``
|
||
|
||
当用户悬停在节点上时,显示系统的拖动鼠标光标,通常是一个闭合的拳头或十字符号。它告诉用户他们当前正在拖动一个项目,例如场景面板中的节点。
|
||
|
||
.. _class_Control_constant_CURSOR_CAN_DROP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_CAN_DROP** = ``7``
|
||
|
||
当用户悬停节点时,显示系统的落地鼠标光标。它可以是一个张开的手。它告诉用户可以放下一个他们当前正在抓取的物品,比如场景面板中的一个节点。
|
||
|
||
.. _class_Control_constant_CURSOR_FORBIDDEN:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_FORBIDDEN** = ``8``
|
||
|
||
当用户悬停节点时,显示系统禁止的鼠标光标。通常是一个交叉的圆圈。
|
||
|
||
.. _class_Control_constant_CURSOR_VSIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_VSIZE** = ``9``
|
||
|
||
当用户悬停节点时,显示系统的垂直调整鼠标光标。一个双头的垂直箭头。它告诉用户可以垂直调整窗口或面板的大小。
|
||
|
||
.. _class_Control_constant_CURSOR_HSIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HSIZE** = ``10``
|
||
|
||
当用户悬停节点时,显示系统的水平调整鼠标光标。一个双头的水平箭头。它告诉用户可以水平调整窗口或面板的大小。
|
||
|
||
.. _class_Control_constant_CURSOR_BDIAGSIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_BDIAGSIZE** = ``11``
|
||
|
||
当用户将节点悬停时,显示系统窗口调整大小的鼠标光标。光标是从左下角到右上角的双向箭头。它告诉用户可以水平和垂直调整窗口或面板的大小。
|
||
|
||
.. _class_Control_constant_CURSOR_FDIAGSIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_FDIAGSIZE** = ``12``
|
||
|
||
当用户将节点悬停时,显示系统窗口调整大小的鼠标光标。光标是一个双向箭头,从左上角到右下角,与 :ref:`CURSOR_BDIAGSIZE<class_Control_constant_CURSOR_BDIAGSIZE>` 相反。它告诉用户可以水平和垂直调整窗口或面板的大小。
|
||
|
||
.. _class_Control_constant_CURSOR_MOVE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_MOVE** = ``13``
|
||
|
||
当用户将节点悬停时,显示系统的移动鼠标光标。它以 90 度角显示 2 个双向箭头。它告诉用户他们可以自由移动 UI 元素。
|
||
|
||
.. _class_Control_constant_CURSOR_VSPLIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_VSPLIT** = ``14``
|
||
|
||
当用户将节点悬停时,显示系统的垂直拆分鼠标光标。在 Windows 上与 :ref:`CURSOR_VSIZE<class_Control_constant_CURSOR_VSIZE>` 相同。
|
||
|
||
.. _class_Control_constant_CURSOR_HSPLIT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HSPLIT** = ``15``
|
||
|
||
当用户将节点悬停时,显示系统的水平拆分鼠标光标。在 Windows 上与 :ref:`CURSOR_HSIZE<class_Control_constant_CURSOR_HSIZE>` 相同。
|
||
|
||
.. _class_Control_constant_CURSOR_HELP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **CURSOR_HELP** = ``16``
|
||
|
||
当用户将节点悬停在一个节点上时,显示系统的帮助鼠标光标,一个问号。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_LayoutPreset:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **LayoutPreset**: :ref:`🔗<enum_Control_LayoutPreset>`
|
||
|
||
.. _class_Control_constant_PRESET_TOP_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_LEFT** = ``0``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的左上角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_TOP_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_RIGHT** = ``1``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的右上角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_BOTTOM_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_LEFT** = ``2``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的左下角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_BOTTOM_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_RIGHT** = ``3``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的右下角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_CENTER_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_LEFT** = ``4``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的左边缘的中点。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_CENTER_TOP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_TOP** = ``5``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的顶边缘的中点。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_CENTER_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_RIGHT** = ``6``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的右边缘的中点。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_CENTER_BOTTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER_BOTTOM** = ``7``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的底边缘的中点。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_CENTER:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_CENTER** = ``8``
|
||
|
||
将所有 4 个锚点对齐到父控件边界的中心。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_LEFT_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_LEFT_WIDE** = ``9``
|
||
|
||
将所有 4 个锚点对齐到父控件的左边缘。左偏移量相对于父节点的左边缘,上偏移量相对于父节点的左上角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_TOP_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_TOP_WIDE** = ``10``
|
||
|
||
将所有 4 个锚点对齐到父控件的上边缘。左偏移量相对于父节点的左上角,上偏移量相对于父节点的上边缘,右偏移相对于父节点的右上角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_RIGHT_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_RIGHT_WIDE** = ``11``
|
||
|
||
将所有 4 个锚点对齐到父控件的右边缘。右偏移量相对于父节点的右边缘,上偏移量相对于父节点的右上角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_BOTTOM_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_BOTTOM_WIDE** = ``12``
|
||
|
||
将所有 4 个锚点对齐到父控件的下边缘。左偏移量相对于父节点的左下角,下偏移量相对于父节点的下边缘,右偏移相对于父节点的右下角。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_VCENTER_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_VCENTER_WIDE** = ``13``
|
||
|
||
将所有 4 个锚点对齐到一条垂直线,该垂直线将父控件切成两半。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_HCENTER_WIDE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_HCENTER_WIDE** = ``14``
|
||
|
||
将所有 4 个锚点对齐到一条水平线,该水平线将父控件切成两半。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. _class_Control_constant_PRESET_FULL_RECT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPreset<enum_Control_LayoutPreset>` **PRESET_FULL_RECT** = ``15``
|
||
|
||
将所有 4 个锚点对齐到父控件对应的角。应用此预设后,会将所有 4 个偏移都设置为 0,该 **Control** 将适合其父控件。与 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 一起使用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_LayoutPresetMode:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **LayoutPresetMode**: :ref:`🔗<enum_Control_LayoutPresetMode>`
|
||
|
||
.. _class_Control_constant_PRESET_MODE_MINSIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_MINSIZE** = ``0``
|
||
|
||
控件将被调整为最小尺寸。
|
||
|
||
.. _class_Control_constant_PRESET_MODE_KEEP_WIDTH:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_WIDTH** = ``1``
|
||
|
||
控件的宽度不会改变。
|
||
|
||
.. _class_Control_constant_PRESET_MODE_KEEP_HEIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_HEIGHT** = ``2``
|
||
|
||
控件的高度不会改变。
|
||
|
||
.. _class_Control_constant_PRESET_MODE_KEEP_SIZE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` **PRESET_MODE_KEEP_SIZE** = ``3``
|
||
|
||
控件的大小不会改变。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_SizeFlags:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
flags **SizeFlags**: :ref:`🔗<enum_Control_SizeFlags>`
|
||
|
||
.. _class_Control_constant_SIZE_SHRINK_BEGIN:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_SHRINK_BEGIN** = ``0``
|
||
|
||
告诉父级 :ref:`Container<class_Container>` 将该节点与其起点对齐,即顶部或左侧。它与 :ref:`SIZE_FILL<class_Control_constant_SIZE_FILL>` 以及其他收缩大小标志互斥,但可以在某些容器中与 :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` 一起使用。与 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` 一起使用。
|
||
|
||
\ **注意:**\ 设置这个标志相当于没有任何大小标志。
|
||
|
||
.. _class_Control_constant_SIZE_FILL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_FILL** = ``1``
|
||
|
||
告诉父级 :ref:`Container<class_Container>` 扩展该节点的边界以填充所有可用空间,而无需推动任何其他节点。它与收缩大小标志互斥。与 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` 一起使用。
|
||
|
||
.. _class_Control_constant_SIZE_EXPAND:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_EXPAND** = ``2``
|
||
|
||
告诉父级 :ref:`Container<class_Container>` 让该节点占用你标记的轴上的所有可用空间。如果将多个相邻节点设置为扩展,它们将根据其拉伸比共享空间。见 :ref:`size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>`\ 。用于 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>`\ 。
|
||
|
||
.. _class_Control_constant_SIZE_EXPAND_FILL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_EXPAND_FILL** = ``3``
|
||
|
||
将该节点的大小标志设置为填充和扩展。有关详细信息,请参阅 :ref:`SIZE_FILL<class_Control_constant_SIZE_FILL>` 和 :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>`\ 。
|
||
|
||
.. _class_Control_constant_SIZE_SHRINK_CENTER:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_SHRINK_CENTER** = ``4``
|
||
|
||
告诉父级 :ref:`Container<class_Container>` 将节点置于可用空间的中心。它与 :ref:`SIZE_FILL<class_Control_constant_SIZE_FILL>` 以及其他收缩大小标志互斥,但可以在某些容器中与 :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` 一起使用。与 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` 一起使用。
|
||
|
||
.. _class_Control_constant_SIZE_SHRINK_END:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`SizeFlags<enum_Control_SizeFlags>` **SIZE_SHRINK_END** = ``8``
|
||
|
||
告诉父级 :ref:`Container<class_Container>` 将节点与其末端对齐,即底部或右侧。它与 :ref:`SIZE_FILL<class_Control_constant_SIZE_FILL>` 以及其他收缩大小标志互斥,但可以在某些容器中与 :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` 一起使用。与 :ref:`size_flags_horizontal<class_Control_property_size_flags_horizontal>` 和 :ref:`size_flags_vertical<class_Control_property_size_flags_vertical>` 一起使用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_MouseFilter:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **MouseFilter**: :ref:`🔗<enum_Control_MouseFilter>`
|
||
|
||
.. _class_Control_constant_MOUSE_FILTER_STOP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_STOP** = ``0``
|
||
|
||
在控件上点击时,将通过 :ref:`_gui_input<class_Control_private_method__gui_input>` 收到鼠标移动输入事件和鼠标按钮输入事件。控件能够接收到 :ref:`mouse_entered<class_Control_signal_mouse_entered>` 和 :ref:`mouse_exited<class_Control_signal_mouse_exited>` 信号。这些事件将自动被标记为已处理,不会进一步传播到其他控件。这也会导致其他控件中的信号被阻止。
|
||
|
||
.. _class_Control_constant_MOUSE_FILTER_PASS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_PASS** = ``1``
|
||
|
||
在控件上点击时,将通过 :ref:`_gui_input<class_Control_private_method__gui_input>` 收到鼠标移动输入事件和鼠标按钮输入事件。并且控件能够接收到 :ref:`mouse_entered<class_Control_signal_mouse_entered>` 和 :ref:`mouse_exited<class_Control_signal_mouse_exited>` 信号。如果此控件不处理事件,则将考虑其父控件(如果有的话),依此类推,直到没有更多的父控件可以处理该事件。这也允许信号在其他控件中触发。如果没有控件处理它,该事件将被传递到 :ref:`Node._shortcut_input<class_Node_private_method__shortcut_input>` 进行进一步处理。
|
||
|
||
.. _class_Control_constant_MOUSE_FILTER_IGNORE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`MouseFilter<enum_Control_MouseFilter>` **MOUSE_FILTER_IGNORE** = ``2``
|
||
|
||
在控件上点击时,不会通过 :ref:`_gui_input<class_Control_private_method__gui_input>` 收到鼠标移动输入事件和鼠标按钮输入事件,也不会接收到 :ref:`mouse_entered<class_Control_signal_mouse_entered>` 和 :ref:`mouse_exited<class_Control_signal_mouse_exited>` 信号。这不会阻止其他控件接收这些事件或触发信号。被忽略的事件将不会被自动处理。
|
||
|
||
\ **注意:**\ 如果控件已收到 :ref:`mouse_entered<class_Control_signal_mouse_entered>` 但未收到 :ref:`mouse_exited<class_Control_signal_mouse_exited>`\ ,则将 :ref:`mouse_filter<class_Control_property_mouse_filter>` 更改为 :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>` 将导致发出 :ref:`mouse_exited<class_Control_signal_mouse_exited>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_GrowDirection:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **GrowDirection**: :ref:`🔗<enum_Control_GrowDirection>`
|
||
|
||
.. _class_Control_constant_GROW_DIRECTION_BEGIN:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_BEGIN** = ``0``
|
||
|
||
如果控件的最小尺寸更改为大于其相应轴上的当前尺寸,则控件将向左或顶部增大以进行组合。
|
||
|
||
.. _class_Control_constant_GROW_DIRECTION_END:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_END** = ``1``
|
||
|
||
如果控件的最小尺寸更改为大于其相应轴上的当前尺寸,则控件将向右或向下增大以进行补偿。
|
||
|
||
.. _class_Control_constant_GROW_DIRECTION_BOTH:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`GrowDirection<enum_Control_GrowDirection>` **GROW_DIRECTION_BOTH** = ``2``
|
||
|
||
如果控件的最小大小更改为大于其当前大小,则控件将在两个方向上均等地增长以组成该控件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_Anchor:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **Anchor**: :ref:`🔗<enum_Control_Anchor>`
|
||
|
||
.. _class_Control_constant_ANCHOR_BEGIN:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`Anchor<enum_Control_Anchor>` **ANCHOR_BEGIN** = ``0``
|
||
|
||
将 4 个锚点的某一侧吸附到节点的 ``Rect`` 的左上角。在 ``anchor_*`` 成员变量中使用,例如 :ref:`anchor_left<class_Control_property_anchor_left>`\ 。要一次更改全部 4 个锚点,请使用 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`\ 。
|
||
|
||
.. _class_Control_constant_ANCHOR_END:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`Anchor<enum_Control_Anchor>` **ANCHOR_END** = ``1``
|
||
|
||
将 4 个锚点的某一侧吸附到节点的 ``Rect`` 的右下角。在 ``anchor_*`` 成员变量中使用,例如 :ref:`anchor_left<class_Control_property_anchor_left>`\ 。要一次更改全部 4 个锚点,请使用 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_LayoutDirection:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **LayoutDirection**: :ref:`🔗<enum_Control_LayoutDirection>`
|
||
|
||
.. _class_Control_constant_LAYOUT_DIRECTION_INHERITED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutDirection<enum_Control_LayoutDirection>` **LAYOUT_DIRECTION_INHERITED** = ``0``
|
||
|
||
自动布局方向,由父控件布局方向决定。
|
||
|
||
.. _class_Control_constant_LAYOUT_DIRECTION_LOCALE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutDirection<enum_Control_LayoutDirection>` **LAYOUT_DIRECTION_LOCALE** = ``1``
|
||
|
||
自动布局方向,根据当前语言环境确定。
|
||
|
||
.. _class_Control_constant_LAYOUT_DIRECTION_LTR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutDirection<enum_Control_LayoutDirection>` **LAYOUT_DIRECTION_LTR** = ``2``
|
||
|
||
从左至右的布局方向。
|
||
|
||
.. _class_Control_constant_LAYOUT_DIRECTION_RTL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`LayoutDirection<enum_Control_LayoutDirection>` **LAYOUT_DIRECTION_RTL** = ``3``
|
||
|
||
从右至左的布局方向。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_Control_TextDirection:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **TextDirection**: :ref:`🔗<enum_Control_TextDirection>`
|
||
|
||
.. _class_Control_constant_TEXT_DIRECTION_INHERITED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`TextDirection<enum_Control_TextDirection>` **TEXT_DIRECTION_INHERITED** = ``3``
|
||
|
||
文字书写方向与布局方向相同。
|
||
|
||
.. _class_Control_constant_TEXT_DIRECTION_AUTO:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`TextDirection<enum_Control_TextDirection>` **TEXT_DIRECTION_AUTO** = ``0``
|
||
|
||
自动文本书写方向,根据当前区域设置和文本内容确定。
|
||
|
||
.. _class_Control_constant_TEXT_DIRECTION_LTR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`TextDirection<enum_Control_TextDirection>` **TEXT_DIRECTION_LTR** = ``1``
|
||
|
||
从左至右的文本书写方向。
|
||
|
||
.. _class_Control_constant_TEXT_DIRECTION_RTL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`TextDirection<enum_Control_TextDirection>` **TEXT_DIRECTION_RTL** = ``2``
|
||
|
||
从右至左的文本书写方向。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
常量
|
||
----
|
||
|
||
.. _class_Control_constant_NOTIFICATION_RESIZED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_RESIZED** = ``40`` :ref:`🔗<class_Control_constant_NOTIFICATION_RESIZED>`
|
||
|
||
当节点改变大小时发送。请使用 :ref:`size<class_Control_property_size>` 获取新大小。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_MOUSE_ENTER:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_MOUSE_ENTER** = ``41`` :ref:`🔗<class_Control_constant_NOTIFICATION_MOUSE_ENTER>`
|
||
|
||
当鼠标光标进入控件(或任何子控件)的可见区域时发送,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到该通知。
|
||
|
||
另见 :ref:`NOTIFICATION_MOUSE_ENTER_SELF<class_Control_constant_NOTIFICATION_MOUSE_ENTER_SELF>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_MOUSE_EXIT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_MOUSE_EXIT** = ``42`` :ref:`🔗<class_Control_constant_NOTIFICATION_MOUSE_EXIT>`
|
||
|
||
当鼠标光标离开控件(以及所有子控件)的可见区域时发送,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到该通知。
|
||
|
||
另见 :ref:`NOTIFICATION_MOUSE_EXIT_SELF<class_Control_constant_NOTIFICATION_MOUSE_EXIT_SELF>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_MOUSE_ENTER_SELF:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_MOUSE_ENTER_SELF** = ``60`` :ref:`🔗<class_Control_constant_NOTIFICATION_MOUSE_ENTER_SELF>`
|
||
|
||
**实验性:** The reason this notification is sent may change in the future.
|
||
|
||
当鼠标光标进入控件的可见区域时发送,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到该通知。
|
||
|
||
另见 :ref:`NOTIFICATION_MOUSE_ENTER<class_Control_constant_NOTIFICATION_MOUSE_ENTER>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_MOUSE_EXIT_SELF:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_MOUSE_EXIT_SELF** = ``61`` :ref:`🔗<class_Control_constant_NOTIFICATION_MOUSE_EXIT_SELF>`
|
||
|
||
**实验性:** The reason this notification is sent may change in the future.
|
||
|
||
当鼠标光标离开控件的可见区域时发送,可见区域即未被其他 Control 和 Window 遮挡的区域,需要 :ref:`mouse_filter<class_Control_property_mouse_filter>` 允许事件达到,与控件是否持有焦点无关。
|
||
|
||
\ **注意:**\ :ref:`CanvasItem.z_index<class_CanvasItem_property_z_index>` 不影响哪个 Control 会收到该通知。
|
||
|
||
另见 :ref:`NOTIFICATION_MOUSE_EXIT<class_Control_constant_NOTIFICATION_MOUSE_EXIT>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_FOCUS_ENTER:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_FOCUS_ENTER** = ``43`` :ref:`🔗<class_Control_constant_NOTIFICATION_FOCUS_ENTER>`
|
||
|
||
当节点获得焦点时发送。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_FOCUS_EXIT:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_FOCUS_EXIT** = ``44`` :ref:`🔗<class_Control_constant_NOTIFICATION_FOCUS_EXIT>`
|
||
|
||
当节点失去焦点时发送。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_THEME_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_THEME_CHANGED** = ``45`` :ref:`🔗<class_Control_constant_NOTIFICATION_THEME_CHANGED>`
|
||
|
||
当节点需要刷新其主题项目时发送。发送时机如下:
|
||
|
||
- 该节点或其任何祖先节点上的 :ref:`theme<class_Control_property_theme>` 属性被更改。
|
||
|
||
- 该节点上的 :ref:`theme_type_variation<class_Control_property_theme_type_variation>` 属性被更改。
|
||
|
||
- 该节点的某个主题属性覆盖被更改。
|
||
|
||
- 该节点进入场景树。
|
||
|
||
\ **注意:**\ 作为一种优化,当该节点在场景树之外时,发生的更改不会发送该通知。相反,所有的主题项更新可以在该节点进入场景树时一次性应用。
|
||
|
||
\ **注意:**\ 该通知与 :ref:`Node.NOTIFICATION_ENTER_TREE<class_Node_constant_NOTIFICATION_ENTER_TREE>` 一同发送,因此,如果你是在实例化场景,那么此时子节点尚未初始化。可以在该通知中设置该节点的主题和用脚本创建的节点的主题,如果你想要访问编辑器中添加的子节点,请使用 :ref:`Node.is_node_ready<class_Node_method_is_node_ready>` 确认节点已就绪。
|
||
|
||
::
|
||
|
||
func _notification(what):
|
||
if what == NOTIFICATION_THEME_CHANGED:
|
||
if not is_node_ready():
|
||
await ready # 等待就绪信号。
|
||
$Label.add_theme_color_override("font_color", Color.YELLOW)
|
||
|
||
.. _class_Control_constant_NOTIFICATION_SCROLL_BEGIN:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_SCROLL_BEGIN** = ``47`` :ref:`🔗<class_Control_constant_NOTIFICATION_SCROLL_BEGIN>`
|
||
|
||
当该节点位于 :ref:`ScrollContainer<class_ScrollContainer>` 内部时发送,该容器在通过\ *触摸事件*\ 拖动该可滚动区域时已开始滚动。通过拖动滚动条滚动、使用鼠标滚轮滚动、或使用键盘/游戏手柄事件滚动时,\ *不*\ 会发送该通知。
|
||
|
||
\ **注意:**\ 该信号仅会在 Android、iOS、桌面、Web 平台上发出,在桌面/Web 平台上需要启用 :ref:`ProjectSettings.input_devices/pointing/emulate_touch_from_mouse<class_ProjectSettings_property_input_devices/pointing/emulate_touch_from_mouse>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_SCROLL_END:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_SCROLL_END** = ``48`` :ref:`🔗<class_Control_constant_NOTIFICATION_SCROLL_END>`
|
||
|
||
当该节点位于 :ref:`ScrollContainer<class_ScrollContainer>` 内部时发送,该容器在通过\ *触摸事件*\ 拖动该可滚动区域时已停止滚动。通过拖动滚动条滚动、使用鼠标滚轮滚动、或使用键盘/游戏手柄事件滚动时,\ *不*\ 会发送该通知。
|
||
|
||
\ **注意:**\ 该信号仅会在 Android、iOS、桌面、Web 平台上发出,在桌面/Web 平台上需要启用 :ref:`ProjectSettings.input_devices/pointing/emulate_touch_from_mouse<class_ProjectSettings_property_input_devices/pointing/emulate_touch_from_mouse>`\ 。
|
||
|
||
.. _class_Control_constant_NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**NOTIFICATION_LAYOUT_DIRECTION_CHANGED** = ``49`` :ref:`🔗<class_Control_constant_NOTIFICATION_LAYOUT_DIRECTION_CHANGED>`
|
||
|
||
当控件的布局方向改变时发送。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
属性说明
|
||
--------
|
||
|
||
.. _class_Control_property_anchor_bottom:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **anchor_bottom** = ``0.0`` :ref:`🔗<class_Control_property_anchor_bottom>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`float<class_float>` **get_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
将节点的底部边缘锚定到父控件的原点、中心或末端。会改变该节点发生移动或改变大小时底部偏移量的更新方式。方便起见,你可以使用 :ref:`Anchor<enum_Control_Anchor>` 常量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_anchor_left:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **anchor_left** = ``0.0`` :ref:`🔗<class_Control_property_anchor_left>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`float<class_float>` **get_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
将节点的左侧边缘锚定到父控件的原点、中心或末端。会改变该节点发生移动或改变大小时左侧偏移量的更新方式。方便起见,你可以使用 :ref:`Anchor<enum_Control_Anchor>` 常量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_anchor_right:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **anchor_right** = ``0.0`` :ref:`🔗<class_Control_property_anchor_right>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`float<class_float>` **get_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
将节点的右侧边缘锚定到父控件的原点、中心或末端。会改变该节点发生移动或改变大小时右侧偏移量的更新方式。方便起见,你可以使用 :ref:`Anchor<enum_Control_Anchor>` 常量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_anchor_top:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **anchor_top** = ``0.0`` :ref:`🔗<class_Control_property_anchor_top>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`float<class_float>` **get_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
将节点的顶部边缘锚定到父控件的原点、中心或末端。会改变该节点发生移动或改变大小时顶部偏移量的更新方式。方便起见,你可以使用 :ref:`Anchor<enum_Control_Anchor>` 常量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_auto_translate:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **auto_translate** :ref:`🔗<class_Control_property_auto_translate>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_auto_translate**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_auto_translating**\ (\ )
|
||
|
||
**已弃用:** Use :ref:`Node.auto_translate_mode<class_Node_property_auto_translate_mode>` instead.
|
||
|
||
切换是否所有文本都应该根据当前区域设置自动变为翻译后的版本。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_clip_contents:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **clip_contents** = ``false`` :ref:`🔗<class_Control_property_clip_contents>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_clip_contents**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_clipping_contents**\ (\ )
|
||
|
||
渲染基于 :ref:`CanvasItem<class_CanvasItem>` 的子节点时,是否应剪裁到该控件的矩形中。如果为 ``true``\ ,则子节点显示在该控件的矩形范围之外的部分,不会渲染,也不会接收输入。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_custom_minimum_size:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **custom_minimum_size** = ``Vector2(0, 0)`` :ref:`🔗<class_Control_property_custom_minimum_size>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_custom_minimum_size**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
|
||
- :ref:`Vector2<class_Vector2>` **get_custom_minimum_size**\ (\ )
|
||
|
||
节点边界矩形的最小尺寸。如果你将它设置为大于 ``(0, 0)`` 的值,节点的边界矩形将始终至少有这个大小。请注意,\ **Control** 节点的 :ref:`get_minimum_size<class_Control_method_get_minimum_size>` 会返回内部最小尺寸,是由控件中的文本、纹理、样式盒等内容决定的,实际的最小尺寸是该属性与内部最小尺寸中的较大值(见 :ref:`get_combined_minimum_size<class_Control_method_get_combined_minimum_size>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_mode:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`FocusMode<enum_Control_FocusMode>` **focus_mode** = ``0`` :ref:`🔗<class_Control_property_focus_mode>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_mode**\ (\ value\: :ref:`FocusMode<enum_Control_FocusMode>`\ )
|
||
- :ref:`FocusMode<enum_Control_FocusMode>` **get_focus_mode**\ (\ )
|
||
|
||
该控件的焦点访问模式(“无”“单击”或“全部”)。只能同时聚焦一个控件,该控件会收到键盘、手柄以及鼠标的信号。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_neighbor_bottom:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_neighbor_bottom** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_neighbor_bottom>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
告诉 Godot 当用户按下键盘上的下方向键或游戏手柄上的下方向键时,默认应该将焦点移交给哪个节点。你可以通过编辑输入动作 :ref:`ProjectSettings.input/ui_down<class_ProjectSettings_property_input/ui_down>` 来修改具体的按键。该节点必须为 **Control**\ 。如果未设置这个属性,Godot 会将焦点移交给该节点下方距离最近的 **Control**\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_neighbor_left:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_neighbor_left** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_neighbor_left>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
告诉 Godot 当用户按下键盘上的左方向键或游戏手柄上的左方向键时,默认应该将焦点移交给哪个节点。你可以通过编辑输入动作 :ref:`ProjectSettings.input/ui_left<class_ProjectSettings_property_input/ui_left>` 来修改具体的按键。该节点必须为 **Control**\ 。如果未设置这个属性,Godot 会将焦点移交给该节点左侧距离最近的 **Control**\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_neighbor_right:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_neighbor_right** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_neighbor_right>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
告诉 Godot 当用户按下键盘上的右方向键或游戏手柄上的右方向键时,默认应该将焦点移交给哪个节点。你可以通过编辑输入动作 :ref:`ProjectSettings.input/ui_right<class_ProjectSettings_property_input/ui_right>` 来修改具体的按键。该节点必须为 **Control**\ 。如果未设置这个属性,Godot 会将焦点移交给该节点右侧距离最近的 **Control**\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_neighbor_top:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_neighbor_top** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_neighbor_top>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
告诉 Godot 当用户按下键盘上的下方向键或游戏手柄上的下方向键时,默认应该将焦点移交给哪个节点。你可以通过编辑输入动作 :ref:`ProjectSettings.input/ui_up<class_ProjectSettings_property_input/ui_up>` 来修改具体的按键。该节点必须为 **Control**\ 。如果未设置这个属性,Godot 会将焦点移交给该节点上方距离最近的 **Control**\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_next:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_next** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_next>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_next**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_next**\ (\ )
|
||
|
||
告诉 Godot 在默认情况下,当用户按下键盘上的 :kbd:`Tab` 时,应将焦点交给哪个节点。你可以通过编辑 :ref:`ProjectSettings.input/ui_focus_next<class_ProjectSettings_property_input/ui_focus_next>` 的输入动作来更改按键。
|
||
|
||
如果未设置此属性,则 Godot 会将根据场景树中的附近节点选择一个“最佳猜测”。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_focus_previous:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **focus_previous** = ``NodePath("")`` :ref:`🔗<class_Control_property_focus_previous>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_focus_previous**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_focus_previous**\ (\ )
|
||
|
||
告诉 Godot 在默认情况下,当用户按下键盘上的 :kbd:`Shift + Tab` 时,应将焦点交给哪个节点。你可以通过编辑 :ref:`ProjectSettings.input/ui_focus_prev<class_ProjectSettings_property_input/ui_focus_prev>` 的输入动作来更改按键。
|
||
|
||
如果未设置此属性,则 Godot 会将根据场景树中的附近节点选择一个“最佳猜测”。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_global_position:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **global_position** :ref:`🔗<class_Control_property_global_position>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_global_position**\ (\ )
|
||
|
||
该节点的全局位置,相对于世界(通常为 :ref:`CanvasLayer<class_CanvasLayer>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_grow_horizontal:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`GrowDirection<enum_Control_GrowDirection>` **grow_horizontal** = ``1`` :ref:`🔗<class_Control_property_grow_horizontal>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_h_grow_direction**\ (\ value\: :ref:`GrowDirection<enum_Control_GrowDirection>`\ )
|
||
- :ref:`GrowDirection<enum_Control_GrowDirection>` **get_h_grow_direction**\ (\ )
|
||
|
||
控制水平轴的方向,如果控件的水平最小尺寸更改为大于其当前尺寸,则控件应沿水平轴增长,因为控件始终必须至少为最小尺寸。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_grow_vertical:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`GrowDirection<enum_Control_GrowDirection>` **grow_vertical** = ``1`` :ref:`🔗<class_Control_property_grow_vertical>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_v_grow_direction**\ (\ value\: :ref:`GrowDirection<enum_Control_GrowDirection>`\ )
|
||
- :ref:`GrowDirection<enum_Control_GrowDirection>` **get_v_grow_direction**\ (\ )
|
||
|
||
控制控件在垂直轴上的方向,如果控件的垂直最小尺寸更改为大于当前尺寸,则控件应沿该方向增大,因为控件始终必须至少为最小尺寸。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_layout_direction:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`LayoutDirection<enum_Control_LayoutDirection>` **layout_direction** = ``0`` :ref:`🔗<class_Control_property_layout_direction>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_layout_direction**\ (\ value\: :ref:`LayoutDirection<enum_Control_LayoutDirection>`\ )
|
||
- :ref:`LayoutDirection<enum_Control_LayoutDirection>` **get_layout_direction**\ (\ )
|
||
|
||
控制布局方向和文本书写方向。某些语言需要从右至左的布局(例如阿拉伯语和希伯来语)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_localize_numeral_system:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **localize_numeral_system** = ``true`` :ref:`🔗<class_Control_property_localize_numeral_system>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_localize_numeral_system**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_localizing_numeral_system**\ (\ )
|
||
|
||
如果为 ``true``\ ,则会自动将代码行号、列表索引号、\ :ref:`SpinBox<class_SpinBox>` 和 :ref:`ProgressBar<class_ProgressBar>` 的值,从阿拉伯数字(0..9)转换为当前区域设置所使用的记数系统。
|
||
|
||
\ **注意:**\ 不会自动转换文本中的数字,可以使用 :ref:`TextServer.format_number<class_TextServer_method_format_number>` 手动转换。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_mouse_default_cursor_shape:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **mouse_default_cursor_shape** = ``0`` :ref:`🔗<class_Control_property_mouse_default_cursor_shape>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_default_cursor_shape**\ (\ value\: :ref:`CursorShape<enum_Control_CursorShape>`\ )
|
||
- :ref:`CursorShape<enum_Control_CursorShape>` **get_default_cursor_shape**\ (\ )
|
||
|
||
此控件的默认光标形状。对于 Godot 插件和使用系统鼠标光标的应用程序或游戏很有用。
|
||
|
||
\ **注意:**\ 在 Linux 上,形状可能会有所不同,具体取决于系统的光标主题。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_mouse_filter:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`MouseFilter<enum_Control_MouseFilter>` **mouse_filter** = ``0`` :ref:`🔗<class_Control_property_mouse_filter>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_mouse_filter**\ (\ value\: :ref:`MouseFilter<enum_Control_MouseFilter>`\ )
|
||
- :ref:`MouseFilter<enum_Control_MouseFilter>` **get_mouse_filter**\ (\ )
|
||
|
||
控制控件是否能够通过 :ref:`_gui_input<class_Control_private_method__gui_input>` 接收鼠标按钮输入事件,以及如何处理这些事件。还控制控件是否能接收 :ref:`mouse_entered<class_Control_signal_mouse_entered>` 和 :ref:`mouse_exited<class_Control_signal_mouse_exited>` 信号。参阅常量来了解每个常量的作用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_mouse_force_pass_scroll_events:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **mouse_force_pass_scroll_events** = ``true`` :ref:`🔗<class_Control_property_mouse_force_pass_scroll_events>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_force_pass_scroll_events**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_force_pass_scroll_events**\ (\ )
|
||
|
||
启用后,即使 :ref:`mouse_filter<class_Control_property_mouse_filter>` 被设置为 :ref:`MOUSE_FILTER_STOP<class_Control_constant_MOUSE_FILTER_STOP>`\ ,由 :ref:`_gui_input<class_Control_private_method__gui_input>` 处理的滚轮事件也会被传递给父控件。由于它默认为“真”,这允许嵌套的可滚动容器可以开箱即用。
|
||
|
||
如果不希望滚动事件进入 :ref:`Node._unhandled_input<class_Node_private_method__unhandled_input>` 处理,则应该在用户界面的根部禁用它。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_offset_bottom:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **offset_bottom** = ``0.0`` :ref:`🔗<class_Control_property_offset_bottom>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_offset**\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
该节点底部边缘与其父控件之间的距离,基于 :ref:`anchor_bottom<class_Control_property_anchor_bottom>`\ 。
|
||
|
||
偏移量通常由一个或多个父 :ref:`Container<class_Container>` 节点控制,因此如果你的节点是 :ref:`Container<class_Container>` 的直接子节点,则不应进行手动修改。移动节点或调整节点大小时,偏移量会自动更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_offset_left:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **offset_left** = ``0.0`` :ref:`🔗<class_Control_property_offset_left>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_offset**\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
该节点左侧边缘与其父控件之间的距离,基于 :ref:`anchor_left<class_Control_property_anchor_left>`\ 。
|
||
|
||
偏移量通常由一个或多个父 :ref:`Container<class_Container>` 节点控制,因此如果你的节点是 :ref:`Container<class_Container>` 的直接子节点,则不应进行手动修改。移动节点或调整节点大小时,偏移量会自动更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_offset_right:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **offset_right** = ``0.0`` :ref:`🔗<class_Control_property_offset_right>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_offset**\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
该节点右侧边缘与其父控件之间的距离,基于 :ref:`anchor_right<class_Control_property_anchor_right>`\ 。
|
||
|
||
偏移量通常由一个或多个父 :ref:`Container<class_Container>` 节点控制,因此如果你的节点是 :ref:`Container<class_Container>` 的直接子节点,则不应进行手动修改。移动节点或调整节点大小时,偏移量会自动更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_offset_top:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **offset_top** = ``0.0`` :ref:`🔗<class_Control_property_offset_top>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_offset**\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
|
||
|
||
该节点顶部边缘与其父控件之间的距离,基于 :ref:`anchor_top<class_Control_property_anchor_top>`\ 。
|
||
|
||
偏移量通常由一个或多个父 :ref:`Container<class_Container>` 节点控制,因此如果你的节点是 :ref:`Container<class_Container>` 的直接子节点,则不应进行手动修改。移动节点或调整节点大小时,偏移量会自动更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_pivot_offset:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **pivot_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Control_property_pivot_offset>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_pivot_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
|
||
- :ref:`Vector2<class_Vector2>` **get_pivot_offset**\ (\ )
|
||
|
||
默认情况下,该节点的轴心位于左上角。更改 :ref:`rotation<class_Control_property_rotation>` 或 :ref:`scale<class_Control_property_scale>` 时,将围绕该轴心进行旋转或缩放。如果将该属性设置为 :ref:`size<class_Control_property_size>` / 2,则围绕的是该控件的中心点。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_position:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **position** = ``Vector2(0, 0)`` :ref:`🔗<class_Control_property_position>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_position**\ (\ )
|
||
|
||
该节点的位置,相对于父节点。对应的是矩形的左上角。该属性不受 :ref:`pivot_offset<class_Control_property_pivot_offset>` 的影响。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_rotation:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **rotation** = ``0.0`` :ref:`🔗<class_Control_property_rotation>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_rotation**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_rotation**\ (\ )
|
||
|
||
该节点围绕其轴心的旋转,单位为弧度。要更改轴心的位置,请参阅 :ref:`pivot_offset<class_Control_property_pivot_offset>`\ 。
|
||
|
||
\ **注意:**\ 该属性在检查器中以度为单位进行编辑。如果要在脚本中使用度数,请使用 :ref:`rotation_degrees<class_Control_property_rotation_degrees>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_rotation_degrees:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **rotation_degrees** :ref:`🔗<class_Control_property_rotation_degrees>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_rotation_degrees**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_rotation_degrees**\ (\ )
|
||
|
||
辅助属性,用于按度数访问 :ref:`rotation<class_Control_property_rotation>` 而不是弧度数。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_scale:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **scale** = ``Vector2(1, 1)`` :ref:`🔗<class_Control_property_scale>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_scale**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
|
||
- :ref:`Vector2<class_Vector2>` **get_scale**\ (\ )
|
||
|
||
节点的缩放,相对于它的 :ref:`size<class_Control_property_size>`\ 。更改该属性以围绕其 :ref:`pivot_offset<class_Control_property_pivot_offset>` 缩放节点。该 Control 的 :ref:`tooltip_text<class_Control_property_tooltip_text>` 也将根据该值进行缩放。
|
||
|
||
\ **注意:**\ 该属性主要用于动画用途。要在项目中支持多种分辨率,请使用 :doc:`文档 <../tutorials/rendering/multiple_resolutions>` 中所述的合适的视口拉伸模式,而不是单独缩放控件。
|
||
|
||
\ **注意:**\ :ref:`FontFile.oversampling<class_FontFile_property_oversampling>` *不*\ 考虑 **Control** :ref:`scale<class_Control_property_scale>`\ 。这意味着放大/缩小会导致位图字体和光栅化(非 MSDF)动态字体显得模糊或像素化。为确保无论缩放比例如何,文本都保持清晰,你可以通过启用 :ref:`ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field<class_ProjectSettings_property_gui/theme/default_font_multichannel_signed_distance_field>`\ (仅适用于默认项目字体);或在自定义字体的 DynamicFont 的导入选项中,启用\ **多通道有符号距离场**\ 来启用 MSDF 字体渲染。对于系统字体,可以在检查器中启用 :ref:`SystemFont.multichannel_signed_distance_field<class_SystemFont_property_multichannel_signed_distance_field>`\ 。
|
||
|
||
\ **注意:**\ 如果该 Control 节点是 :ref:`Container<class_Container>` 节点的子节点,则场景实例化时,缩放将重置为 ``Vector2(1, 1)``\ 。要在实例化时设置控件的缩放,请使用 ``await get_tree().process_frame`` 等待一帧,然后再设置其 :ref:`scale<class_Control_property_scale>` 属性。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_shortcut_context:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Node<class_Node>` **shortcut_context** :ref:`🔗<class_Control_property_shortcut_context>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_shortcut_context**\ (\ value\: :ref:`Node<class_Node>`\ )
|
||
- :ref:`Node<class_Node>` **get_shortcut_context**\ (\ )
|
||
|
||
该 :ref:`Node<class_Node>` 必须是被聚焦 **Control** 的父节点,才能激活快捷方式。如果为 ``null``\ ,则可以在任何控件获得焦点时激活该快捷方式(全局快捷方式)。这允许快捷方式只在用户聚焦 GUI 的特定区域时才被接受。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_size:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Vector2<class_Vector2>` **size** = ``Vector2(0, 0)`` :ref:`🔗<class_Control_property_size>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- :ref:`Vector2<class_Vector2>` **get_size**\ (\ )
|
||
|
||
该节点的边界矩形的大小,使用该节点的坐标系。\ :ref:`Container<class_Container>` 节点会自动更新此属性。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_size_flags_horizontal:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
|bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] **size_flags_horizontal** = ``1`` :ref:`🔗<class_Control_property_size_flags_horizontal>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_h_size_flags**\ (\ value\: |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\]\ )
|
||
- |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] **get_h_size_flags**\ (\ )
|
||
|
||
告诉父 :ref:`Container<class_Container>` 节点应如何调整尺寸并将其放置在 X 轴上。请使用 :ref:`SizeFlags<enum_Control_SizeFlags>` 常量的组合来更改标志。查看常量以了解每个常量的作用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_size_flags_stretch_ratio:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **size_flags_stretch_ratio** = ``1.0`` :ref:`🔗<class_Control_property_size_flags_stretch_ratio>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_stretch_ratio**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_stretch_ratio**\ (\ )
|
||
|
||
如果该节点及其至少一个邻居节点使用 :ref:`SIZE_EXPAND<class_Control_constant_SIZE_EXPAND>` 大小标志,则父 :ref:`Container<class_Container>` 将根据该属性让它占用更多或更少的空间。如果该节点的拉伸比为 2,其邻居节点的拉伸比为 1,则该节点将占用三分之二的可用空间。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_size_flags_vertical:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
|bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] **size_flags_vertical** = ``1`` :ref:`🔗<class_Control_property_size_flags_vertical>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_v_size_flags**\ (\ value\: |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\]\ )
|
||
- |bitfield|\[:ref:`SizeFlags<enum_Control_SizeFlags>`\] **get_v_size_flags**\ (\ )
|
||
|
||
告诉父 :ref:`Container<class_Container>` 节点应如何调整尺寸并将其放置在 Y 轴上。请使用 :ref:`SizeFlags<enum_Control_SizeFlags>` 常量的组合来更改标志。查看常量以了解每个常量的作用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_theme:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`Theme<class_Theme>` **theme** :ref:`🔗<class_Control_property_theme>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_theme**\ (\ value\: :ref:`Theme<class_Theme>`\ )
|
||
- :ref:`Theme<class_Theme>` **get_theme**\ (\ )
|
||
|
||
该节点及其子 **Control** 和 :ref:`Window<class_Window>` 所使用的 :ref:`Theme<class_Theme>` 资源。如果子节点也设置了 :ref:`Theme<class_Theme>` 资源,则会合并主题项,子节点的定义优先级更高。
|
||
|
||
\ **注意:**\ 除非 :ref:`Window<class_Window>` 为嵌入式,否则窗口样式无效。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_theme_type_variation:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`StringName<class_StringName>` **theme_type_variation** = ``&""`` :ref:`🔗<class_Control_property_theme_type_variation>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_theme_type_variation**\ (\ value\: :ref:`StringName<class_StringName>`\ )
|
||
- :ref:`StringName<class_StringName>` **get_theme_type_variation**\ (\ )
|
||
|
||
该 **Control** 用于查找其自有的主题项的主题类型变体的名称。当为空时,将使用节点的类名(例如 ``Button`` 用于 :ref:`Button<class_Button>` 控件),以及所有父类的类名(按继承顺序)。
|
||
|
||
设置后,该属性将最高优先级赋予指定名称的类型。这种类型又可以扩展另一种类型,形成依赖链。参见 :ref:`Theme.set_type_variation<class_Theme_method_set_type_variation>`\ 。如果使用该类型或其基类型无法找到主题项,则查找会回退到依赖类名查找。
|
||
|
||
\ **注意:**\ 要查找 **Control** 自有的项目,请使用各种 ``get_theme_*`` 方法且无需指定 ``theme_type``\ 。
|
||
|
||
\ **注意:**\ 主题项按树状顺序查找,从分支到根,其中每个 **Control** 节点的 :ref:`theme<class_Control_property_theme>` 属性都将被检查。最早匹配任意类型名称/类名称的项将被返回。最后检查项目级的主题和默认主题。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_property_tooltip_text:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`String<class_String>` **tooltip_text** = ``""`` :ref:`🔗<class_Control_property_tooltip_text>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_tooltip_text**\ (\ value\: :ref:`String<class_String>`\ )
|
||
- :ref:`String<class_String>` **get_tooltip_text**\ (\ )
|
||
|
||
默认工具提示文本。如果 :ref:`mouse_filter<class_Control_property_mouse_filter>` 属性不是 :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>`\ ,则当用户的鼠标光标在此控件上停留片刻时,将出现工具提示。可以使用 :ref:`ProjectSettings.gui/timers/tooltip_delay_sec<class_ProjectSettings_property_gui/timers/tooltip_delay_sec>` 选项更改工具提示出现所需的时间。另见 :ref:`get_tooltip<class_Control_method_get_tooltip>`\ 。
|
||
|
||
工具提示弹出窗口将使用默认实现,或者使用通过覆盖 :ref:`_make_custom_tooltip<class_Control_private_method__make_custom_tooltip>` 提供的自定义实现。默认工具提示包括一个 :ref:`PopupPanel<class_PopupPanel>` 和 :ref:`Label<class_Label>`\ ,其主题属性可以使用 :ref:`Theme<class_Theme>` 方法分别对 ``"TooltipPanel"`` 和 ``"TooltipLabel"`` 进行自定义。例如:
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
var style_box = StyleBoxFlat.new()
|
||
style_box.set_bg_color(Color(1, 1, 0))
|
||
style_box.set_border_width_all(2)
|
||
# 我们在这里假设`Theme`属性已经被事先分配了一个自定义的主题。
|
||
theme.set_stylebox("panel", "TooltipPanel", style_box)
|
||
theme.set_color("font_color", "TooltipLabel", Color(0, 1, 1))
|
||
|
||
.. code-tab:: csharp
|
||
|
||
var styleBox = new StyleBoxFlat();
|
||
styleBox.SetBgColor(new Color(1, 1, 0));
|
||
styleBox.SetBorderWidthAll(2);
|
||
// 我们在这里假设`Theme`属性已经被事先分配了一个自定义的主题。
|
||
Theme.SetStyleBox("panel", "TooltipPanel", styleBox);
|
||
Theme.SetColor("font_color", "TooltipLabel", new Color(0, 1, 1));
|
||
|
||
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法说明
|
||
--------
|
||
|
||
.. _class_Control_private_method__can_drop_data:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_can_drop_data**\ (\ at_position\: :ref:`Vector2<class_Vector2>`, data\: :ref:`Variant<class_Variant>`\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__can_drop_data>`
|
||
|
||
Godot 调用这个方法来检查是否能够将来自某个控件 :ref:`_get_drag_data<class_Control_private_method__get_drag_data>` 方法的 ``data`` 拖放到 ``at_position``\ 。\ ``at_position`` 使用的是这个控件的局部坐标系。
|
||
|
||
这个方法应该只用于检查数据。请在 :ref:`_drop_data<class_Control_private_method__drop_data>` 中处理数据。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _can_drop_data(position, data):
|
||
# 如果和位置相关就检查 position
|
||
# 否则只检查 data 即可
|
||
return typeof(data) == TYPE_DICTIONARY and data.has("expected")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||
{
|
||
// 如果和位置相关就检查 position
|
||
// 否则只检查 data 即可
|
||
return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().ContainsKey("expected");
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__drop_data:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_drop_data**\ (\ at_position\: :ref:`Vector2<class_Vector2>`, data\: :ref:`Variant<class_Variant>`\ ) |virtual| :ref:`🔗<class_Control_private_method__drop_data>`
|
||
|
||
Godot 调用该方法把 ``data`` 传给你,这是从某个控件的 :ref:`_get_drag_data<class_Control_private_method__get_drag_data>` 获得的结果。Godot 首先会调用 :ref:`_can_drop_data<class_Control_private_method__can_drop_data>` 来检查是否允许把 ``data`` 拖放到 ``at_position``\ ,这里的 ``at_position`` 使用的是这个控件的局部坐标系。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _can_drop_data(position, data):
|
||
return typeof(data) == TYPE_DICTIONARY and data.has("color")
|
||
|
||
func _drop_data(position, data):
|
||
var color = data["color"]
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||
{
|
||
return data.VariantType == Variant.Type.Dictionary && dict.AsGodotDictionary().ContainsKey("color");
|
||
}
|
||
|
||
public override void _DropData(Vector2 atPosition, Variant data)
|
||
{
|
||
Color color = data.AsGodotDictionary()["color"].AsColor();
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__get_drag_data:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **_get_drag_data**\ (\ at_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| :ref:`🔗<class_Control_private_method__get_drag_data>`
|
||
|
||
Godot 调用该方法来获取数据,这个数据将用于拖动操作,放置到期望放置数据的控件上。如果没有要拖动的数据,则返回 ``null``\ 。想要接收拖放数据的控件应该实现 :ref:`_can_drop_data<class_Control_private_method__can_drop_data>` 和 :ref:`_drop_data<class_Control_private_method__drop_data>`\ 。\ ``at_position`` 是该控件的局部位置。可以使用 :ref:`force_drag<class_Control_method_force_drag>` 强制拖动。
|
||
|
||
可以使用 :ref:`set_drag_preview<class_Control_method_set_drag_preview>` 设置跟随鼠标显示数据的预览。本方法中非常适合设置这个预览。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _get_drag_data(position):
|
||
var mydata = make_data() # This is your custom method generating the drag data.
|
||
set_drag_preview(make_preview(mydata)) # 这是你生成拖动数据预览的自定义方法。
|
||
return mydata
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override Variant _GetDragData(Vector2 atPosition)
|
||
{
|
||
var myData = MakeData(); // This is your custom method generating the drag data.
|
||
SetDragPreview(MakePreview(myData)); // 这是你生成拖动数据预览的自定义方法。
|
||
return myData;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__get_minimum_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **_get_minimum_size**\ (\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__get_minimum_size>`
|
||
|
||
由用户实现的虚方法。返回此控件的最小大小。替代 :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>`\ ,以用于通过代码控制最小尺寸。实际的最小尺寸将是这两者的最大值(分别在每个轴上)。
|
||
|
||
如果未覆盖,则默认为 :ref:`Vector2.ZERO<class_Vector2_constant_ZERO>`\ 。
|
||
|
||
\ **注意:**\ 当脚本被附加到已经覆盖其最小大小的 **Control** 节点(例如 :ref:`Label<class_Label>`\ 、\ :ref:`Button<class_Button>`\ 、\ :ref:`PanelContainer<class_PanelContainer>` 等)时,该方法将不会被调用。它只能用于最基本的 GUI 节点,如 **Control**\ 、\ :ref:`Container<class_Container>`\ 、\ :ref:`Panel<class_Panel>` 等。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__get_tooltip:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_tooltip**\ (\ at_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__get_tooltip>`
|
||
|
||
用户实现的虚方法。返回位于控件局部坐标系中 ``at_position`` 位置的工具提示文本,工具提示一般会在鼠标停留在该控件上时显示。见 :ref:`get_tooltip<class_Control_method_get_tooltip>`\ 。
|
||
|
||
\ **注意:**\ 如果返回的是空 :ref:`String<class_String>`\ ,则不会显示工具提示。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__gui_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **_gui_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) |virtual| :ref:`🔗<class_Control_private_method__gui_input>`
|
||
|
||
由用户实现的虚方法。使用此方法处理和接受 UI 元素上的输入。请参阅 :ref:`accept_event<class_Control_method_accept_event>`\ 。
|
||
|
||
\ **点击控件的用法示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _gui_input(event):
|
||
if event is InputEventMouseButton:
|
||
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||
print("我已被点击 D:")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override void _GuiInput(InputEvent @event)
|
||
{
|
||
if (@event is InputEventMouseButton mb)
|
||
{
|
||
if (mb.ButtonIndex == MouseButton.Left && mb.Pressed)
|
||
{
|
||
GD.Print("我已被点击 D:");
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
如果出现以下情况,则不会触发该事件:
|
||
|
||
\* 在控件外点击(参阅\ :ref:`_has_point<class_Control_private_method__has_point>`\ );
|
||
|
||
\* 控件将 :ref:`mouse_filter<class_Control_property_mouse_filter>` 设置为 :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>`\ ;
|
||
|
||
\* 控件被其上的另一个 **Control** 阻挡,该控件没有将 :ref:`mouse_filter<class_Control_property_mouse_filter>` 设置为 :ref:`MOUSE_FILTER_IGNORE<class_Control_constant_MOUSE_FILTER_IGNORE>`\ ;
|
||
|
||
\* 控件的父级已将 :ref:`mouse_filter<class_Control_property_mouse_filter>` 设置为 :ref:`MOUSE_FILTER_STOP<class_Control_constant_MOUSE_FILTER_STOP>` 或已接受该事件;
|
||
|
||
\* 它发生在父级的矩形之外,并且父级已启用 :ref:`clip_contents<class_Control_property_clip_contents>`\ 。
|
||
|
||
\ **注意:**\ 事件位置相对于该控件原点。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__has_point:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_has_point**\ (\ point\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__has_point>`
|
||
|
||
由用户实现的虚方法。返回给定的 ``point`` 是否在该控件内。
|
||
|
||
如果没有被覆盖,则默认行为是检查该点是否在控件的 Rect 内。
|
||
|
||
\ **注意:**\ 如果要检查一个点是否在该控件内部,可以使用 ``Rect2(Vector2.ZERO, size).has_point(point)``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__make_custom_tooltip:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Object<class_Object>` **_make_custom_tooltip**\ (\ for_text\: :ref:`String<class_String>`\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__make_custom_tooltip>`
|
||
|
||
由用户实现的虚方法。返回一个 **Control** 节点,该节点取代默认节点以用作工具提示。\ ``for_text`` 包含 :ref:`tooltip_text<class_Control_property_tooltip_text>` 属性的内容。
|
||
|
||
返回的节点必须是 **Control** 类型或 Control 派生类型。它可以有任何类型的子节点。当工具提示消失时它会被释放,因此请确保你始终提供一个新实例(如果你想使用场景树中预先存在的节点,你可以复制它并传递复制的实例)。当返回 ``null`` 或非控制节点时,将使用默认的工具提示。
|
||
|
||
返回的节点将作为子节点添加到 :ref:`PopupPanel<class_PopupPanel>`\ ,因此你应该只提供该面板的内容。该 :ref:`PopupPanel<class_PopupPanel>` 可以使用 :ref:`Theme.set_stylebox<class_Theme_method_set_stylebox>` 为类型 ``"TooltipPanel"`` 设置主题(参见 :ref:`tooltip_text<class_Control_property_tooltip_text>` 示例)。
|
||
|
||
\ **注意:**\ 工具提示会被缩小到最小大小。如果你想确保它完全可见,你可能需要将其 :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>` 设置为非零值。
|
||
|
||
\ **注意:**\ 返回时节点(和任何相关的子节点)应该是 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>`\ ,否则,实例化它的视口将无法可靠地计算它的最小大小。
|
||
|
||
\ **自定义构造节点的用法示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _make_custom_tooltip(for_text):
|
||
var label = Label.new()
|
||
label.text = for_text
|
||
return label
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override Control _MakeCustomTooltip(string forText)
|
||
{
|
||
var label = new Label();
|
||
label.Text = forText;
|
||
return label;
|
||
}
|
||
|
||
|
||
|
||
\ **自定义场景实例的使用示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _make_custom_tooltip(for_text):
|
||
var tooltip = preload("res://some_tooltip_scene.tscn").instantiate()
|
||
tooltip.get_node("Label").text = for_text
|
||
return tooltip
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override Control _MakeCustomTooltip(string forText)
|
||
{
|
||
Node tooltip = ResourceLoader.Load<PackedScene>("res://some_tooltip_scene.tscn").Instantiate();
|
||
tooltip.GetNode<Label>("Label").Text = forText;
|
||
return tooltip;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_private_method__structured_text_parser:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Array<class_Array>`\[:ref:`Vector3i<class_Vector3i>`\] **_structured_text_parser**\ (\ args\: :ref:`Array<class_Array>`, text\: :ref:`String<class_String>`\ ) |virtual| |const| :ref:`🔗<class_Control_private_method__structured_text_parser>`
|
||
|
||
用户定义的 BiDi 算法覆盖函数。
|
||
|
||
返回 :ref:`Vector3i<class_Vector3i>` 文本范围和文本基础方向的 :ref:`Array<class_Array>`\ ,顺序为从左至右。这些范围应该覆盖完整的来源文本 ``text``\ ,不应该存在重叠。BiDi 算法会对每个范围单独应用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_accept_event:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **accept_event**\ (\ ) :ref:`🔗<class_Control_method_accept_event>`
|
||
|
||
将输入事件标记为已处理。一旦接受输入事件,传播就会停止,不会再传播到正在侦听 :ref:`Node._unhandled_input<class_Node_private_method__unhandled_input>` 和 :ref:`Node._unhandled_key_input<class_Node_private_method__unhandled_key_input>` 的节点。
|
||
|
||
\ **注意:**\ 不会影响 :ref:`Input<class_Input>` 中的方法,只会影响事件的传播。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_color_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_color_override**\ (\ name\: :ref:`StringName<class_StringName>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Control_method_add_theme_color_override>`
|
||
|
||
为名称为 ``name`` 的主题 :ref:`Color<class_Color>` 创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_color_override<class_Control_method_remove_theme_color_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
\ **覆盖标签颜色并在之后重置的示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 存在名叫“MyLabel”的子 Label 节点,使用自定义的值覆盖其字体颜色。
|
||
$MyLabel.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||
# 重置该子标签的字体颜色。
|
||
$MyLabel.remove_theme_color_override("font_color")
|
||
# 也可以使用 Label 类型的默认值覆盖。
|
||
$MyLabel.add_theme_color_override("font_color", get_theme_color("font_color", "Label"))
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 存在名叫“MyLabel”的子 Label 节点,使用自定义的值覆盖其字体颜色。
|
||
GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0));
|
||
// 重置该子标签的字体颜色。
|
||
GetNode<Label>("MyLabel").RemoveThemeColorOverride("font_color");
|
||
// 也可以使用 Label 类型的默认值覆盖。
|
||
GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", GetThemeColor("font_color", "Label"));
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_constant_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_constant_override**\ (\ name\: :ref:`StringName<class_StringName>`, constant\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Control_method_add_theme_constant_override>`
|
||
|
||
为名称为 ``name`` 的主题常量创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_constant_override<class_Control_method_remove_theme_constant_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_constant<class_Control_method_get_theme_constant>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_font_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_font_override**\ (\ name\: :ref:`StringName<class_StringName>`, font\: :ref:`Font<class_Font>`\ ) :ref:`🔗<class_Control_method_add_theme_font_override>`
|
||
|
||
为名称为 ``name`` 的主题 :ref:`Font<class_Font>` 创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_font_override<class_Control_method_remove_theme_font_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_font<class_Control_method_get_theme_font>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_font_size_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_font_size_override**\ (\ name\: :ref:`StringName<class_StringName>`, font_size\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Control_method_add_theme_font_size_override>`
|
||
|
||
为名称为 ``name`` 的主题字体大小创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_font_size_override<class_Control_method_remove_theme_font_size_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_font_size<class_Control_method_get_theme_font_size>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_icon_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_icon_override**\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`\ ) :ref:`🔗<class_Control_method_add_theme_icon_override>`
|
||
|
||
为名称为 ``name`` 的主题图标创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_icon_override<class_Control_method_remove_theme_icon_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_icon<class_Control_method_get_theme_icon>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_add_theme_stylebox_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_theme_stylebox_override**\ (\ name\: :ref:`StringName<class_StringName>`, stylebox\: :ref:`StyleBox<class_StyleBox>`\ ) :ref:`🔗<class_Control_method_add_theme_stylebox_override>`
|
||
|
||
为名称为 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_stylebox_override<class_Control_method_remove_theme_stylebox_override>` 移除。
|
||
|
||
另见 :ref:`get_theme_stylebox<class_Control_method_get_theme_stylebox>`\ 。
|
||
|
||
\ **通过创建副本来修改 StyleBox 属性的示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 以下代码片段要求子节点 MyButton 分配了 StyleBoxFlat。
|
||
# 资源是跨实例共享的,因此我们需要制作其副本
|
||
# 来避免修改其他所有按钮的外观。
|
||
var new_stylebox_normal = $MyButton.get_theme_stylebox("normal").duplicate()
|
||
new_stylebox_normal.border_width_top = 3
|
||
new_stylebox_normal.border_color = Color(0, 1, 0.5)
|
||
$MyButton.add_theme_stylebox_override("normal", new_stylebox_normal)
|
||
# 移除样式盒覆盖项。
|
||
$MyButton.remove_theme_stylebox_override("normal")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 以下代码片段要求子节点 MyButton 分配了 StyleBoxFlat。
|
||
// 资源是跨实例共享的,因此我们需要制作其副本
|
||
// 来避免修改其他所有按钮的外观。
|
||
StyleBoxFlat newStyleboxNormal = GetNode<Button>("MyButton").GetThemeStylebox("normal").Duplicate() as StyleBoxFlat;
|
||
newStyleboxNormal.BorderWidthTop = 3;
|
||
newStyleboxNormal.BorderColor = new Color(0, 1, 0.5f);
|
||
GetNode<Button>("MyButton").AddThemeStyleboxOverride("normal", newStyleboxNormal);
|
||
// 移除样式盒覆盖项。
|
||
GetNode<Button>("MyButton").RemoveThemeStyleboxOverride("normal");
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_begin_bulk_theme_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **begin_bulk_theme_override**\ (\ ) :ref:`🔗<class_Control_method_begin_bulk_theme_override>`
|
||
|
||
防止 ``*_theme_*_override`` 方法发出 :ref:`NOTIFICATION_THEME_CHANGED<class_Control_constant_NOTIFICATION_THEME_CHANGED>`\ ,直到 :ref:`end_bulk_theme_override<class_Control_method_end_bulk_theme_override>` 被调用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_end_bulk_theme_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **end_bulk_theme_override**\ (\ ) :ref:`🔗<class_Control_method_end_bulk_theme_override>`
|
||
|
||
结束批量主题覆盖更新。见 :ref:`begin_bulk_theme_override<class_Control_method_begin_bulk_theme_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_find_next_valid_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Control<class_Control>` **find_next_valid_focus**\ (\ ) |const| :ref:`🔗<class_Control_method_find_next_valid_focus>`
|
||
|
||
找到下一个可以接受焦点的 **Control**\ ,在树的下方。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_find_prev_valid_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Control<class_Control>` **find_prev_valid_focus**\ (\ ) |const| :ref:`🔗<class_Control_method_find_prev_valid_focus>`
|
||
|
||
找到上一个可以接受焦点的 **Control**\ ,在树的上方。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_find_valid_focus_neighbor:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Control<class_Control>` **find_valid_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Control_method_find_valid_focus_neighbor>`
|
||
|
||
查找指定 :ref:`Side<enum_@GlobalScope_Side>` 上可以接收焦点的下一个 **Control**\ 。
|
||
|
||
\ **注意:**\ 这与 :ref:`get_focus_neighbor<class_Control_method_get_focus_neighbor>` 不同,后者返回指定焦点邻居的路径。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_force_drag:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **force_drag**\ (\ data\: :ref:`Variant<class_Variant>`, preview\: :ref:`Control<class_Control>`\ ) :ref:`🔗<class_Control_method_force_drag>`
|
||
|
||
通过传递 ``data`` 和 ``preview`` 强制拖动并绕过 :ref:`_get_drag_data<class_Control_private_method__get_drag_data>` 和 :ref:`set_drag_preview<class_Control_method_set_drag_preview>`\ 。即使鼠标既没有在该控件悬停也没有在该控件上按下,拖动都将开始。
|
||
|
||
方法 :ref:`_can_drop_data<class_Control_private_method__can_drop_data>` 和 :ref:`_drop_data<class_Control_private_method__drop_data>` 必须在想要接收拖放数据的控件上实现。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_anchor:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Control_method_get_anchor>`
|
||
|
||
返回指定 :ref:`Side<enum_@GlobalScope_Side>` 的锚点。用于 :ref:`anchor_bottom<class_Control_property_anchor_bottom>`\ 、\ :ref:`anchor_left<class_Control_property_anchor_left>`\ 、\ :ref:`anchor_right<class_Control_property_anchor_right>` 和 :ref:`anchor_top<class_Control_property_anchor_top>` 的取值方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_begin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_begin**\ (\ ) |const| :ref:`🔗<class_Control_method_get_begin>`
|
||
|
||
返回 :ref:`offset_left<class_Control_property_offset_left>` 和 :ref:`offset_top<class_Control_property_offset_top>`\ 。另请参阅 :ref:`position<class_Control_property_position>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_combined_minimum_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_combined_minimum_size**\ (\ ) |const| :ref:`🔗<class_Control_method_get_combined_minimum_size>`
|
||
|
||
返回 :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>` 和 :ref:`get_minimum_size<class_Control_method_get_minimum_size>` 的组合最小大小。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_cursor_shape:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`CursorShape<enum_Control_CursorShape>` **get_cursor_shape**\ (\ position\: :ref:`Vector2<class_Vector2>` = Vector2(0, 0)\ ) |const| :ref:`🔗<class_Control_method_get_cursor_shape>`
|
||
|
||
返回控件在鼠标悬停时显示的鼠标指针形状。见 :ref:`CursorShape<enum_Control_CursorShape>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_end:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_end**\ (\ ) |const| :ref:`🔗<class_Control_method_get_end>`
|
||
|
||
返回 :ref:`offset_right<class_Control_property_offset_right>` 和 :ref:`offset_bottom<class_Control_property_offset_bottom>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_focus_neighbor:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`NodePath<class_NodePath>` **get_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Control_method_get_focus_neighbor>`
|
||
|
||
返回指定 :ref:`Side<enum_@GlobalScope_Side>` 的焦点邻居。用于 :ref:`focus_neighbor_bottom<class_Control_property_focus_neighbor_bottom>`\ 、\ :ref:`focus_neighbor_left<class_Control_property_focus_neighbor_left>`\ 、\ :ref:`focus_neighbor_right<class_Control_property_focus_neighbor_right>` 和 :ref:`focus_neighbor_top<class_Control_property_focus_neighbor_top>` 的取值方法。
|
||
|
||
\ **注意:**\ 要查找特定 :ref:`Side<enum_@GlobalScope_Side>` 上的下一个 **Control**\ ,即使未指定邻居,也请使用 :ref:`find_valid_focus_neighbor<class_Control_method_find_valid_focus_neighbor>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_global_rect:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Rect2<class_Rect2>` **get_global_rect**\ (\ ) |const| :ref:`🔗<class_Control_method_get_global_rect>`
|
||
|
||
返回控件相对于所属画布的位置和大小。参见 :ref:`global_position<class_Control_property_global_position>` 和 :ref:`size<class_Control_property_size>`\ 。
|
||
|
||
\ **注意:**\ 如果节点本身或节点与画布之间的任何父级 :ref:`CanvasItem<class_CanvasItem>` 具有非默认旋转或倾斜,则生成的大小可能没有意义。
|
||
|
||
\ **注意:**\ 将 :ref:`Viewport.gui_snap_controls_to_pixels<class_Viewport_property_gui_snap_controls_to_pixels>` 设置为 ``true`` 会导致显示的控件和返回的 :ref:`Rect2<class_Rect2>` 之间的舍入不准确。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_minimum_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_minimum_size**\ (\ ) |const| :ref:`🔗<class_Control_method_get_minimum_size>`
|
||
|
||
返回该控件的最小尺寸。见 :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_offset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_offset**\ (\ offset\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Control_method_get_offset>`
|
||
|
||
返回指定 :ref:`Side<enum_@GlobalScope_Side>` 的偏移。这是 :ref:`offset_bottom<class_Control_property_offset_bottom>`\ 、\ :ref:`offset_left<class_Control_property_offset_left>`\ 、\ :ref:`offset_right<class_Control_property_offset_right>` 和 :ref:`offset_top<class_Control_property_offset_top>` 的 getter 方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_parent_area_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_parent_area_size**\ (\ ) |const| :ref:`🔗<class_Control_method_get_parent_area_size>`
|
||
|
||
返回父控件中占用的宽度/高度。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_parent_control:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Control<class_Control>` **get_parent_control**\ (\ ) |const| :ref:`🔗<class_Control_method_get_parent_control>`
|
||
|
||
返回父控制节点。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_rect:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Rect2<class_Rect2>` **get_rect**\ (\ ) |const| :ref:`🔗<class_Control_method_get_rect>`
|
||
|
||
返回控件在包含节点的坐标系中的位置和大小。参见 :ref:`position<class_Control_property_position>`\ 、\ :ref:`scale<class_Control_property_scale>` 和 :ref:`size<class_Control_property_size>`\ 。
|
||
|
||
\ **注意:**\ 如果 :ref:`rotation<class_Control_property_rotation>` 不是默认的旋转,那么得到的大小是没有意义的。
|
||
|
||
\ **注意:**\ 将 :ref:`Viewport.gui_snap_controls_to_pixels<class_Viewport_property_gui_snap_controls_to_pixels>` 设置为 ``true``\ ,会导致显示的控件和返回的 :ref:`Rect2<class_Rect2>` 之间的舍入不准确。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_screen_position:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Vector2<class_Vector2>` **get_screen_position**\ (\ ) |const| :ref:`🔗<class_Control_method_get_screen_position>`
|
||
|
||
返回该 **Control** 在全局屏幕坐标系中的位置(即考虑窗口的位置)。主要用于编辑器插件。
|
||
|
||
如果窗口是嵌入式的,则等于 :ref:`global_position<class_Control_property_global_position>`\ (见 :ref:`Viewport.gui_embed_subwindows<class_Viewport_property_gui_embed_subwindows>`\ )。
|
||
|
||
\ **显示弹出框的用法示例:**\
|
||
|
||
::
|
||
|
||
popup_menu.position = get_screen_position() + get_local_mouse_position()
|
||
popup_menu.reset_size()
|
||
popup_menu.popup()
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_color:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Color<class_Color>` **get_theme_color**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_color>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回 :ref:`Color<class_Color>`\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的颜色项。如果省略 ``theme_type`` 则会使用当前控件的类名,如果定义了 :ref:`theme_type_variation<class_Control_property_theme_type_variation>` 则会优先使用。如果该类型为类名,则还会按照继承顺序检查父类。如果该类型为变种,则还会按照依赖顺序检查基础类型,然后再检查该控件的类名及其父类。
|
||
|
||
会首先考虑当前控件的本地覆盖项(见 :ref:`add_theme_color_override<class_Control_method_add_theme_color_override>`\ ),然后才是其 :ref:`theme<class_Control_property_theme>`\ 。各个父控件及其 :ref:`theme<class_Control_property_theme>` 在当前控件之后考虑;会跳过没有 :ref:`theme<class_Control_property_theme>` 的控件。如果树中没有匹配的 :ref:`Theme<class_Theme>`\ ,则会使用自定义项目 :ref:`Theme<class_Theme>`\ (见 :ref:`ProjectSettings.gui/theme/custom<class_ProjectSettings_property_gui/theme/custom>`\ )和默认 :ref:`Theme<class_Theme>`\ (见 :ref:`ThemeDB<class_ThemeDB>`\ )。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _ready():
|
||
# 获取当前 Control 类中定义的字体颜色,前提是存在。
|
||
modulate = get_theme_color("font_color")
|
||
# 获取 Button 类中定义的字体颜色。
|
||
modulate = get_theme_color("font_color", "Button")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override void _Ready()
|
||
{
|
||
// 获取当前 Control 类中定义的字体颜色,前提是存在。
|
||
Modulate = GetThemeColor("font_color");
|
||
// 获取 Button 类中定义的字体颜色。
|
||
Modulate = GetThemeColor("font_color", "Button");
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_constant:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_theme_constant**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_constant>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回常量,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的常量项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_default_base_scale:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_theme_default_base_scale**\ (\ ) |const| :ref:`🔗<class_Control_method_get_theme_default_base_scale>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回默认基础缩放值,该 :ref:`Theme<class_Theme>` 中应存在有效的 :ref:`Theme.default_base_scale<class_Theme_property_default_base_scale>` 值。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_default_font:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Font<class_Font>` **get_theme_default_font**\ (\ ) |const| :ref:`🔗<class_Control_method_get_theme_default_font>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回默认字体,该 :ref:`Theme<class_Theme>` 中应存在有效的 :ref:`Theme.default_font<class_Theme_property_default_font>` 值。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_default_font_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_theme_default_font_size**\ (\ ) |const| :ref:`🔗<class_Control_method_get_theme_default_font_size>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回默认字体大小,该 :ref:`Theme<class_Theme>` 中应存在有效的 :ref:`Theme.default_font_size<class_Theme_property_default_font_size>` 值。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_font:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Font<class_Font>` **get_theme_font**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_font>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回 :ref:`Font<class_Font>`\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的字体项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_font_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_theme_font_size**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_font_size>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回字体大小,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的字体大小项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_icon:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Texture2D<class_Texture2D>` **get_theme_icon**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_icon>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回图标,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的图标项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_theme_stylebox:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`StyleBox<class_StyleBox>` **get_theme_stylebox**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_get_theme_stylebox>`
|
||
|
||
从树中第一个匹配的 :ref:`Theme<class_Theme>` 返回 :ref:`StyleBox<class_StyleBox>`\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的样式盒项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_get_tooltip:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **get_tooltip**\ (\ at_position\: :ref:`Vector2<class_Vector2>` = Vector2(0, 0)\ ) |const| :ref:`🔗<class_Control_method_get_tooltip>`
|
||
|
||
返回位于该控件局部坐标系中 ``at_position`` 位置的工具提示文本,工具提示一般会在鼠标停留在该控件上时显示。默认情况下返回的是 :ref:`tooltip_text<class_Control_property_tooltip_text>`\ 。
|
||
|
||
覆盖这个方法可以自定义行为。见 :ref:`_get_tooltip<class_Control_private_method__get_tooltip>`\ 。
|
||
|
||
\ **注意:**\ 如果返回的是空 :ref:`String<class_String>`\ ,则不会显示工具提示。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_grab_click_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **grab_click_focus**\ (\ ) :ref:`🔗<class_Control_method_grab_click_focus>`
|
||
|
||
创建一个尝试点击控件的 :ref:`InputEventMouseButton<class_InputEventMouseButton>`\ 。如果收到该事件,则该控件将获得焦点。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _process(delta):
|
||
grab_click_focus() # 点击另一个控制节点时,将改为点击该节点。
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override void _Process(double delta)
|
||
{
|
||
GrabClickFocus(); // 点击另一个控制节点时,将改为点击该节点。
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_grab_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **grab_focus**\ (\ ) :ref:`🔗<class_Control_method_grab_focus>`
|
||
|
||
从别的控件上窃取焦点,从而成为聚焦的控件(见 :ref:`focus_mode<class_Control_property_focus_mode>`\ )。
|
||
|
||
\ **注意:**\ 这个方法与 :ref:`Object.call_deferred<class_Object_method_call_deferred>` 配合使用会更加可靠,尤其是在 :ref:`Node._ready<class_Node_private_method__ready>` 中调用时。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_focus**\ (\ ) |const| :ref:`🔗<class_Control_method_has_focus>`
|
||
|
||
如果这是当前的焦点控件,则返回 ``true``\ 。见 :ref:`focus_mode<class_Control_property_focus_mode>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_color:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_color**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_color>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的颜色项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_color_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_color_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_color_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题 :ref:`Color<class_Color>` 本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_color_override<class_Control_method_add_theme_color_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_constant:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_constant**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_constant>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的常量项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_constant_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_constant_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_constant_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题常量本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_constant_override<class_Control_method_add_theme_constant_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_font:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_font**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_font>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的字体项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_font_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_font_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_font_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题 :ref:`Font<class_Font>` 本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_font_override<class_Control_method_add_theme_font_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_font_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_font_size**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_font_size>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的字体大小项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_font_size_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_font_size_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_font_size_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题字体大小本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_font_size_override<class_Control_method_add_theme_font_size_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_icon:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_icon**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_icon>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的图标项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_icon_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_icon_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_icon_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题图标本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_icon_override<class_Control_method_add_theme_icon_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_stylebox:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_stylebox**\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Control_method_has_theme_stylebox>`
|
||
|
||
如果树中存在匹配的 :ref:`Theme<class_Theme>` 则返回 ``true``\ ,该 :ref:`Theme<class_Theme>` 中应存在指定名称 ``name`` 和主题类型 ``theme_type`` 的样式盒项。
|
||
|
||
详情请参阅 :ref:`get_theme_color<class_Control_method_get_theme_color>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_has_theme_stylebox_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_theme_stylebox_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_Control_method_has_theme_stylebox_override>`
|
||
|
||
如果该 **Control** 节点中存在名为指定 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 本地覆盖项,则返回 ``true``\ 。
|
||
|
||
详情请参阅 :ref:`add_theme_stylebox_override<class_Control_method_add_theme_stylebox_override>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_is_drag_successful:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_drag_successful**\ (\ ) |const| :ref:`🔗<class_Control_method_is_drag_successful>`
|
||
|
||
如果拖放操作成功则返回 ``true``\ ,是 :ref:`Viewport.gui_is_drag_successful<class_Viewport_method_gui_is_drag_successful>` 的替代方案。
|
||
|
||
建议与 :ref:`Node.NOTIFICATION_DRAG_END<class_Node_constant_NOTIFICATION_DRAG_END>` 配合使用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_is_layout_rtl:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **is_layout_rtl**\ (\ ) |const| :ref:`🔗<class_Control_method_is_layout_rtl>`
|
||
|
||
如果布局是从右至左的,则返回 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_release_focus:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **release_focus**\ (\ ) :ref:`🔗<class_Control_method_release_focus>`
|
||
|
||
放弃焦点。不会让其他控件能够接收键盘输入。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_color_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_color_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_color_override>`
|
||
|
||
移除名为指定 ``name`` 的主题 :ref:`Color<class_Color>` 本地覆盖项,该覆盖项由 :ref:`add_theme_color_override<class_Control_method_add_theme_color_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_constant_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_constant_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_constant_override>`
|
||
|
||
移除名为指定 ``name`` 的主题常量本地覆盖项,该覆盖项由 :ref:`add_theme_constant_override<class_Control_method_add_theme_constant_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_font_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_font_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_font_override>`
|
||
|
||
移除名为指定 ``name`` 的主题 :ref:`Font<class_Font>` 本地覆盖项,该覆盖项由 :ref:`add_theme_font_override<class_Control_method_add_theme_font_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_font_size_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_font_size_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_font_size_override>`
|
||
|
||
移除名为指定 ``name`` 的主题字体大小本地覆盖项,该覆盖项由 :ref:`add_theme_font_size_override<class_Control_method_add_theme_font_size_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_icon_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_icon_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_icon_override>`
|
||
|
||
移除名为指定 ``name`` 的主题图标本地覆盖项,该覆盖项由 :ref:`add_theme_icon_override<class_Control_method_add_theme_icon_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_remove_theme_stylebox_override:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_theme_stylebox_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Control_method_remove_theme_stylebox_override>`
|
||
|
||
移除名为指定 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 本地覆盖项,该覆盖项由 :ref:`add_theme_stylebox_override<class_Control_method_add_theme_stylebox_override>` 或检查器面板添加的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_reset_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **reset_size**\ (\ ) :ref:`🔗<class_Control_method_reset_size>`
|
||
|
||
将大小重置为 :ref:`get_combined_minimum_size<class_Control_method_get_combined_minimum_size>`\ 。等价于调用 ``set_size(Vector2())``\ (或任何小于最小值的大小)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_anchor:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_anchor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, anchor\: :ref:`float<class_float>`, keep_offset\: :ref:`bool<class_bool>` = false, push_opposite_anchor\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_Control_method_set_anchor>`
|
||
|
||
将指定 :ref:`Side<enum_@GlobalScope_Side>` 的锚点设置为 ``anchor``\ 。用于 :ref:`anchor_bottom<class_Control_property_anchor_bottom>`\ 、\ :ref:`anchor_left<class_Control_property_anchor_left>`\ 、\ :ref:`anchor_right<class_Control_property_anchor_right>` 和 :ref:`anchor_top<class_Control_property_anchor_top>` 的设值函数。
|
||
|
||
如果 ``keep_offset`` 为 ``true``\ ,则偏移量不会在该操作后更新。
|
||
|
||
如果 ``push_opposite_anchor`` 为 ``true``\ ,并且相对的锚点与该锚点重叠,则相对的锚点的值将被覆盖。例如,当将左锚点设置为 1 且右锚点的值为 0.5 时,右锚点的值也将为 1。如果 ``push_opposite_anchor`` 为 ``false``\ ,则左锚点的值将为 0.5。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_anchor_and_offset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_anchor_and_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, anchor\: :ref:`float<class_float>`, offset\: :ref:`float<class_float>`, push_opposite_anchor\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Control_method_set_anchor_and_offset>`
|
||
|
||
工作原理与 :ref:`set_anchor<class_Control_method_set_anchor>` 相同,但取代 ``keep_offset`` 参数和自动更新的偏移,它允许你自己设置偏移量(参见 :ref:`set_offset<class_Control_method_set_offset>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_anchors_and_offsets_preset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_anchors_and_offsets_preset**\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, resize_mode\: :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` = 0, margin\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_Control_method_set_anchors_and_offsets_preset>`
|
||
|
||
设置锚点预设和偏移预设。参见 :ref:`set_anchors_preset<class_Control_method_set_anchors_preset>` 和 :ref:`set_offsets_preset<class_Control_method_set_offsets_preset>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_anchors_preset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_anchors_preset**\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Control_method_set_anchors_preset>`
|
||
|
||
将锚点设置为 :ref:`LayoutPreset<enum_Control_LayoutPreset>` 枚举中的 ``preset``\ 。这是相当于在 2D 编辑器中使用布局菜单的代码。
|
||
|
||
如果 ``keep_offsets`` 为 ``true``\ ,则控件的位置也将被更新。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_begin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_begin**\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Control_method_set_begin>`
|
||
|
||
同时设置 :ref:`offset_left<class_Control_property_offset_left>` 和 :ref:`offset_top<class_Control_property_offset_top>`\ 。相当于改变 :ref:`position<class_Control_property_position>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_drag_forwarding:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_drag_forwarding**\ (\ drag_func\: :ref:`Callable<class_Callable>`, can_drop_func\: :ref:`Callable<class_Callable>`, drop_func\: :ref:`Callable<class_Callable>`\ ) :ref:`🔗<class_Control_method_set_drag_forwarding>`
|
||
|
||
转发该控件的 :ref:`_get_drag_data<class_Control_private_method__get_drag_data>`\ 、\ :ref:`_can_drop_data<class_Control_private_method__can_drop_data>` 和 :ref:`_drop_data<class_Control_private_method__drop_data>` 虚函数的处理,以委托给可调用体。
|
||
|
||
对于每个参数,如果不为空,则使用委托的可调用体,否则使用本地(虚)函数。
|
||
|
||
每个可调用体的函数格式应该与上面描述的虚函数完全相同。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_drag_preview:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_drag_preview**\ (\ control\: :ref:`Control<class_Control>`\ ) :ref:`🔗<class_Control_method_set_drag_preview>`
|
||
|
||
在鼠标指针处显示给定的控件。调用此方法的好时机是在 :ref:`_get_drag_data<class_Control_private_method__get_drag_data>` 中。控件不得位于场景树中。你不应释放控件,也不应在拖动持续时间之外保留对控件的引用。拖拽结束后它会自动删除。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
@export var color = Color(1, 0, 0, 1)
|
||
|
||
func _get_drag_data(position):
|
||
#使用不在树中的控件
|
||
var cpb = ColorPickerButton.new()
|
||
cpb.color = color
|
||
cpb.size = Vector2(50, 50)
|
||
set_drag_preview(cpb)
|
||
return color
|
||
|
||
.. code-tab:: csharp
|
||
|
||
[Export]
|
||
private Color _color = new Color(1, 0, 0, 1);
|
||
|
||
public override Variant _GetDragData(Vector2 atPosition)
|
||
{
|
||
// 使用不在树中的控件
|
||
var cpb = new ColorPickerButton();
|
||
cpb.Color = _color;
|
||
cpb.Size = new Vector2(50, 50);
|
||
SetDragPreview(cpb);
|
||
return _color;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_end:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_end**\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Control_method_set_end>`
|
||
|
||
同时设置 :ref:`offset_right<class_Control_property_offset_right>` 和 :ref:`offset_bottom<class_Control_property_offset_bottom>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_focus_neighbor:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_focus_neighbor**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, neighbor\: :ref:`NodePath<class_NodePath>`\ ) :ref:`🔗<class_Control_method_set_focus_neighbor>`
|
||
|
||
将指定 :ref:`Side<enum_@GlobalScope_Side>` 的焦点邻居设置为节点路径 ``neighbor`` 处的 **Control**\ 。这是 :ref:`focus_neighbor_bottom<class_Control_property_focus_neighbor_bottom>`\ 、\ :ref:`focus_neighbor_left<class_Control_property_focus_neighbor_left>`\ 、\ :ref:`focus_neighbor_right<class_Control_property_focus_neighbor_right>` 和 :ref:`focus_neighbor_top<class_Control_property_focus_neighbor_top>` 的 setter 方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_global_position:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_global_position**\ (\ position\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Control_method_set_global_position>`
|
||
|
||
将 :ref:`global_position<class_Control_property_global_position>` 设置为给定的 ``position``\ 。
|
||
|
||
如果 ``keep_offsets`` 为 ``true``\ ,则将更新控件的锚点而不是偏移量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_offset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_offset**\ (\ side\: :ref:`Side<enum_@GlobalScope_Side>`, offset\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Control_method_set_offset>`
|
||
|
||
将指定 :ref:`Side<enum_@GlobalScope_Side>` 的偏移设置为 ``offset``\ 。用于 :ref:`offset_bottom<class_Control_property_offset_bottom>`\ 、\ :ref:`offset_left<class_Control_property_offset_left>`\ 、\ :ref:`offset_right<class_Control_property_offset_right>` 和 :ref:`offset_top<class_Control_property_offset_top>` 的设值方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_offsets_preset:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_offsets_preset**\ (\ preset\: :ref:`LayoutPreset<enum_Control_LayoutPreset>`, resize_mode\: :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` = 0, margin\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_Control_method_set_offsets_preset>`
|
||
|
||
将偏移设置为 :ref:`LayoutPreset<enum_Control_LayoutPreset>` 枚举中的 ``preset``\ 。这是相当于在 2D 编辑器中使用布局菜单的代码。
|
||
|
||
将参数 ``resize_mode`` 与 :ref:`LayoutPresetMode<enum_Control_LayoutPresetMode>` 中的常量一起使用,以更好地确定 **Control** 的最终大小。如果与更改尺寸大小的预设一起使用,则将忽略常量尺寸大小,例如 :ref:`PRESET_LEFT_WIDE<class_Control_constant_PRESET_LEFT_WIDE>`\ 。
|
||
|
||
使用参数 ``margin`` 来确定 **Control** 和边缘之间的间隙。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_position:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_position**\ (\ position\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Control_method_set_position>`
|
||
|
||
将 :ref:`position<class_Control_property_position>` 设置为给定的 ``position``\ 。
|
||
|
||
如果 ``keep_offsets`` 为 ``true``\ ,则将更新控件的锚点而不是偏移量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_set_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **set_size**\ (\ size\: :ref:`Vector2<class_Vector2>`, keep_offsets\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Control_method_set_size>`
|
||
|
||
设置大小(参见 :ref:`size<class_Control_property_size>`\ )。
|
||
|
||
如果 ``keep_offsets`` 为 ``true``\ ,则将更新控件的锚点而不是偏移量。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_update_minimum_size:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **update_minimum_size**\ (\ ) :ref:`🔗<class_Control_method_update_minimum_size>`
|
||
|
||
使该节点和直至顶级的父节点中的大小缓存无效。旨在当返回值更改时与 :ref:`get_minimum_size<class_Control_method_get_minimum_size>` 一起使用。直接设置 :ref:`custom_minimum_size<class_Control_property_custom_minimum_size>` 将自动调用该方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_Control_method_warp_mouse:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **warp_mouse**\ (\ position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Control_method_warp_mouse>`
|
||
|
||
将鼠标光标移动到 ``position``\ ,相对于该 **Control** 的 :ref:`position<class_Control_property_position>`\ 。
|
||
|
||
\ **注意:**\ :ref:`warp_mouse<class_Control_method_warp_mouse>` 仅在 Windows、macOS 和 Linux 上受支持。它在 Android、iOS 和 Web 上没有效果。
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
|
||
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
|
||
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
|
||
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
|
||
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
|
||
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
|
||
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
|
||
.. |void| replace:: :abbr:`void (无返回值。)`
|