Files
godot-docs-l10n/classes/zh_Hans/class_window.rst
Rémi Verschelde c3f2364c10 Sync classref with 4.6 branch
Lots of translations invalidated (fuzzied) as we just synced Weblate.
2025-12-19 16:39:51 +01:00

2937 lines
158 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_Window:
Window
======
**继承:** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
**派生:** :ref:`AcceptDialog<class_AcceptDialog>`, :ref:`Popup<class_Popup>`
所有窗口、对话框、弹出框的基类。
.. rst-class:: classref-introduction-group
描述
----
创建窗口的节点。窗口可以是原生系统窗口,也可以是嵌入到其他 **Window** 中的窗口(见 :ref:`Viewport.gui_embed_subwindows<class_Viewport_property_gui_embed_subwindows>`\ )。
运行时,\ **Window** 不会在请求关闭时自动关闭。你需要使用 :ref:`close_requested<class_Window_signal_close_requested>` 信号手动处理(适用于点击关闭按钮和点击弹出窗口外部)。
.. rst-class:: classref-reftable-group
属性
----
.. table::
:widths: auto
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`String<class_String>` | :ref:`accessibility_description<class_Window_property_accessibility_description>` | ``""`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`String<class_String>` | :ref:`accessibility_name<class_Window_property_accessibility_name>` | ``""`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`always_on_top<class_Window_property_always_on_top>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`auto_translate<class_Window_property_auto_translate>` | |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`borderless<class_Window_property_borderless>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` | :ref:`content_scale_aspect<class_Window_property_content_scale_aspect>` | ``0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`float<class_float>` | :ref:`content_scale_factor<class_Window_property_content_scale_factor>` | ``1.0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`ContentScaleMode<enum_Window_ContentScaleMode>` | :ref:`content_scale_mode<class_Window_property_content_scale_mode>` | ``0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`content_scale_size<class_Window_property_content_scale_size>` | ``Vector2i(0, 0)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>` | :ref:`content_scale_stretch<class_Window_property_content_scale_stretch>` | ``0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`int<class_int>` | :ref:`current_screen<class_Window_property_current_screen>` | |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`exclude_from_capture<class_Window_property_exclude_from_capture>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`exclusive<class_Window_property_exclusive>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`extend_to_title<class_Window_property_extend_to_title>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`force_native<class_Window_property_force_native>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` | :ref:`initial_position<class_Window_property_initial_position>` | ``0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`keep_title_visible<class_Window_property_keep_title_visible>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`max_size<class_Window_property_max_size>` | ``Vector2i(0, 0)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`maximize_disabled<class_Window_property_maximize_disabled>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`min_size<class_Window_property_min_size>` | ``Vector2i(0, 0)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`minimize_disabled<class_Window_property_minimize_disabled>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Mode<enum_Window_Mode>` | :ref:`mode<class_Window_property_mode>` | ``0`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`mouse_passthrough<class_Window_property_mouse_passthrough>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`mouse_passthrough_polygon<class_Window_property_mouse_passthrough_polygon>` | ``PackedVector2Array()`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Rect2i<class_Rect2i>` | :ref:`nonclient_area<class_Window_property_nonclient_area>` | ``Rect2i(0, 0, 0, 0)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`popup_window<class_Window_property_popup_window>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`popup_wm_hint<class_Window_property_popup_wm_hint>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`position<class_Window_property_position>` | ``Vector2i(0, 0)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`sharp_corners<class_Window_property_sharp_corners>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`size<class_Window_property_size>` | ``Vector2i(100, 100)`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`Theme<class_Theme>` | :ref:`theme<class_Window_property_theme>` | |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`StringName<class_StringName>` | :ref:`theme_type_variation<class_Window_property_theme_type_variation>` | ``&""`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`String<class_String>` | :ref:`title<class_Window_property_title>` | ``""`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`transient<class_Window_property_transient>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`transient_to_focused<class_Window_property_transient_to_focused>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`transparent<class_Window_property_transparent>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`unfocusable<class_Window_property_unfocusable>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`unresizable<class_Window_property_unresizable>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`visible<class_Window_property_visible>` | ``true`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
| :ref:`bool<class_bool>` | :ref:`wrap_controls<class_Window_property_wrap_controls>` | ``false`` |
+-----------------------------------------------------------------+-----------------------------------------------------------------------------------+--------------------------+
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`_get_contents_minimum_size<class_Window_private_method__get_contents_minimum_size>`\ (\ ) |virtual| |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_color_override<class_Window_method_add_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`, color\: :ref:`Color<class_Color>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_constant_override<class_Window_method_add_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`, constant\: :ref:`int<class_int>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_font_override<class_Window_method_add_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`, font\: :ref:`Font<class_Font>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_font_size_override<class_Window_method_add_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`, font_size\: :ref:`int<class_int>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_icon_override<class_Window_method_add_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_theme_stylebox_override<class_Window_method_add_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`, stylebox\: :ref:`StyleBox<class_StyleBox>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`begin_bulk_theme_override<class_Window_method_begin_bulk_theme_override>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`can_draw<class_Window_method_can_draw>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`child_controls_changed<class_Window_method_child_controls_changed>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`end_bulk_theme_override<class_Window_method_end_bulk_theme_override>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_contents_minimum_size<class_Window_method_get_contents_minimum_size>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_flag<class_Window_method_get_flag>`\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Window<class_Window>` | :ref:`get_focused_window<class_Window_method_get_focused_window>`\ (\ ) |static| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`LayoutDirection<enum_Window_LayoutDirection>` | :ref:`get_layout_direction<class_Window_method_get_layout_direction>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_position_with_decorations<class_Window_method_get_position_with_decorations>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2i<class_Vector2i>` | :ref:`get_size_with_decorations<class_Window_method_get_size_with_decorations>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_Color>` | :ref:`get_theme_color<class_Window_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_Window_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_Window_method_get_theme_default_base_scale>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Font<class_Font>` | :ref:`get_theme_default_font<class_Window_method_get_theme_default_font>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_theme_default_font_size<class_Window_method_get_theme_default_font_size>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Font<class_Font>` | :ref:`get_theme_font<class_Window_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_Window_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_Window_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_Window_method_get_theme_stylebox>`\ (\ name\: :ref:`StringName<class_StringName>`, theme_type\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_window_id<class_Window_method_get_window_id>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`grab_focus<class_Window_method_grab_focus>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_focus<class_Window_method_has_focus>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_color<class_Window_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_Window_method_has_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_constant<class_Window_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_Window_method_has_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_font<class_Window_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_Window_method_has_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_font_size<class_Window_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_Window_method_has_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_icon<class_Window_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_Window_method_has_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_theme_stylebox<class_Window_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_Window_method_has_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`hide<class_Window_method_hide>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_embedded<class_Window_method_is_embedded>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_layout_rtl<class_Window_method_is_layout_rtl>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_maximize_allowed<class_Window_method_is_maximize_allowed>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_using_font_oversampling<class_Window_method_is_using_font_oversampling>`\ (\ ) |const| |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`move_to_center<class_Window_method_move_to_center>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`move_to_foreground<class_Window_method_move_to_foreground>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup<class_Window_method_popup>`\ (\ rect\: :ref:`Rect2i<class_Rect2i>` = Rect2i(0, 0, 0, 0)\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_centered<class_Window_method_popup_centered>`\ (\ minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0)\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_centered_clamped<class_Window_method_popup_centered_clamped>`\ (\ minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0), fallback_ratio\: :ref:`float<class_float>` = 0.75\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_centered_ratio<class_Window_method_popup_centered_ratio>`\ (\ ratio\: :ref:`float<class_float>` = 0.8\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_exclusive<class_Window_method_popup_exclusive>`\ (\ from_node\: :ref:`Node<class_Node>`, rect\: :ref:`Rect2i<class_Rect2i>` = Rect2i(0, 0, 0, 0)\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_exclusive_centered<class_Window_method_popup_exclusive_centered>`\ (\ from_node\: :ref:`Node<class_Node>`, minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0)\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_exclusive_centered_clamped<class_Window_method_popup_exclusive_centered_clamped>`\ (\ from_node\: :ref:`Node<class_Node>`, minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0), fallback_ratio\: :ref:`float<class_float>` = 0.75\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_exclusive_centered_ratio<class_Window_method_popup_exclusive_centered_ratio>`\ (\ from_node\: :ref:`Node<class_Node>`, ratio\: :ref:`float<class_float>` = 0.8\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_exclusive_on_parent<class_Window_method_popup_exclusive_on_parent>`\ (\ from_node\: :ref:`Node<class_Node>`, parent_rect\: :ref:`Rect2i<class_Rect2i>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`popup_on_parent<class_Window_method_popup_on_parent>`\ (\ parent_rect\: :ref:`Rect2i<class_Rect2i>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_color_override<class_Window_method_remove_theme_color_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_constant_override<class_Window_method_remove_theme_constant_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_font_override<class_Window_method_remove_theme_font_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_font_size_override<class_Window_method_remove_theme_font_size_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_icon_override<class_Window_method_remove_theme_icon_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_theme_stylebox_override<class_Window_method_remove_theme_stylebox_override>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`request_attention<class_Window_method_request_attention>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`reset_size<class_Window_method_reset_size>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_flag<class_Window_method_set_flag>`\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_ime_active<class_Window_method_set_ime_active>`\ (\ active\: :ref:`bool<class_bool>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_ime_position<class_Window_method_set_ime_position>`\ (\ position\: :ref:`Vector2i<class_Vector2i>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_layout_direction<class_Window_method_set_layout_direction>`\ (\ direction\: :ref:`LayoutDirection<enum_Window_LayoutDirection>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_unparent_when_invisible<class_Window_method_set_unparent_when_invisible>`\ (\ unparent\: :ref:`bool<class_bool>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_use_font_oversampling<class_Window_method_set_use_font_oversampling>`\ (\ enable\: :ref:`bool<class_bool>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`show<class_Window_method_show>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`start_drag<class_Window_method_start_drag>`\ (\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`start_resize<class_Window_method_start_resize>`\ (\ edge\: :ref:`WindowResizeEdge<enum_DisplayServer_WindowResizeEdge>`\ ) |
+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
主题属性
--------
.. table::
:widths: auto
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Color<class_Color>` | :ref:`title_color<class_Window_theme_color_title_color>` | ``Color(0.875, 0.875, 0.875, 1)`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Color<class_Color>` | :ref:`title_outline_modulate<class_Window_theme_color_title_outline_modulate>` | ``Color(0, 0, 0, 1)`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`close_h_offset<class_Window_theme_constant_close_h_offset>` | ``18`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`close_v_offset<class_Window_theme_constant_close_v_offset>` | ``24`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`resize_margin<class_Window_theme_constant_resize_margin>` | ``4`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`title_height<class_Window_theme_constant_title_height>` | ``36`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`title_outline_size<class_Window_theme_constant_title_outline_size>` | ``0`` |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Font<class_Font>` | :ref:`title_font<class_Window_theme_font_title_font>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`title_font_size<class_Window_theme_font_size_title_font_size>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`close<class_Window_theme_icon_close>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`close_pressed<class_Window_theme_icon_close_pressed>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`StyleBox<class_StyleBox>` | :ref:`embedded_border<class_Window_theme_style_embedded_border>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
| :ref:`StyleBox<class_StyleBox>` | :ref:`embedded_unfocused_border<class_Window_theme_style_embedded_unfocused_border>` | |
+-----------------------------------+--------------------------------------------------------------------------------------+-----------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
信号
----
.. _class_Window_signal_about_to_popup:
.. rst-class:: classref-signal
**about_to_popup**\ (\ ) :ref:`🔗<class_Window_signal_about_to_popup>`
在调用 :ref:`popup()<class_Window_method_popup>` 之后但在 **Window** 出现或执行任何操作之前发送的信号。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_close_requested:
.. rst-class:: classref-signal
**close_requested**\ (\ ) :ref:`🔗<class_Window_signal_close_requested>`
按下该 **Window** 的关闭按钮或启用 :ref:`popup_window<class_Window_property_popup_window>` 并且用户在窗口外点击时发出。
这个信号可以用来处理窗口的关闭,例如将其连接到 :ref:`hide()<class_Window_method_hide>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_dpi_changed:
.. rst-class:: classref-signal
**dpi_changed**\ (\ ) :ref:`🔗<class_Window_signal_dpi_changed>`
**Window** 的 DPI 由于操作系统级别的更改而发生更改时发出(例如将该窗口从 Retina 屏幕移动到了更低分辨率的屏幕)。
\ **注意:**\ 仅在 macOS 和 LinuxWayland上实现。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_files_dropped:
.. rst-class:: classref-signal
**files_dropped**\ (\ files\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) :ref:`🔗<class_Window_signal_files_dropped>`
将文件从操作系统文件管理器拖放到游戏窗口时发出。参数为文件路径列表。
::
func _ready():
get_window().files_dropped.connect(on_files_dropped)
func on_files_dropped(files):
print(files)
\ **注意:**\ 该信号仅对原生窗口有效,即主窗口及主视口禁用 :ref:`Viewport.gui_embed_subwindows<class_Viewport_property_gui_embed_subwindows>` 时的 **Window** 派生节点。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_focus_entered:
.. rst-class:: classref-signal
**focus_entered**\ (\ ) :ref:`🔗<class_Window_signal_focus_entered>`
当该 **Window** 获得焦点时发出。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_focus_exited:
.. rst-class:: classref-signal
**focus_exited**\ (\ ) :ref:`🔗<class_Window_signal_focus_exited>`
当该 **Window** 失去焦点时发出。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_go_back_requested:
.. rst-class:: classref-signal
**go_back_requested**\ (\ ) :ref:`🔗<class_Window_signal_go_back_requested>`
发送返回请求时,在 :ref:`Node.NOTIFICATION_WM_GO_BACK_REQUEST<class_Node_constant_NOTIFICATION_WM_GO_BACK_REQUEST>` 之后发出(例如在 Android 上按下“返回”按钮)。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_mouse_entered:
.. rst-class:: classref-signal
**mouse_entered**\ (\ ) :ref:`🔗<class_Window_signal_mouse_entered>`
当鼠标光标进入 **Window** 的可见区域时发出,该区域未被其他 :ref:`Control<class_Control>` 或窗口遮挡,只要其 :ref:`Viewport.gui_disable_input<class_Viewport_property_gui_disable_input>```false`` 并且无论它当前聚焦与否。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_mouse_exited:
.. rst-class:: classref-signal
**mouse_exited**\ (\ ) :ref:`🔗<class_Window_signal_mouse_exited>`
当鼠标光标离开 **Window** 的可见区域时发出,该区域未被其他 :ref:`Control<class_Control>` 或窗口遮挡,只要其 :ref:`Viewport.gui_disable_input<class_Viewport_property_gui_disable_input>```false`` 并且无论它当前聚焦与否。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_nonclient_window_input:
.. rst-class:: classref-signal
**nonclient_window_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_Window_signal_nonclient_window_input>`
Emitted when the mouse event is received by the custom decoration area defined by :ref:`nonclient_area<class_Window_property_nonclient_area>`, and normal input to the window is blocked (such as when it has an exclusive child opened). ``event``'s position is in the embedder's coordinate system.
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_theme_changed:
.. rst-class:: classref-signal
**theme_changed**\ (\ ) :ref:`🔗<class_Window_signal_theme_changed>`
发送 :ref:`NOTIFICATION_THEME_CHANGED<class_Window_constant_NOTIFICATION_THEME_CHANGED>` 通知时发出。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_title_changed:
.. rst-class:: classref-signal
**title_changed**\ (\ ) :ref:`🔗<class_Window_signal_title_changed>`
当窗口标题栏文本发生变化时发出。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_titlebar_changed:
.. rst-class:: classref-signal
**titlebar_changed**\ (\ ) :ref:`🔗<class_Window_signal_titlebar_changed>`
窗口标题栏装饰发生改变时发出,例如 macOS 窗口进入/退出全屏模式,或者“扩展至标题”标志发生改变。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_visibility_changed:
.. rst-class:: classref-signal
**visibility_changed**\ (\ ) :ref:`🔗<class_Window_signal_visibility_changed>`
显示或隐藏该 **Window** 时发出。
.. rst-class:: classref-item-separator
----
.. _class_Window_signal_window_input:
.. rst-class:: classref-signal
**window_input**\ (\ event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_Window_signal_window_input>`
**Window** 持有焦点并收到任何输入时发出,会把收到的事件作为参数传入。该事件如果存在位置属性,该位置使用嵌入器的坐标系。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
枚举
----
.. _enum_Window_Mode:
.. rst-class:: classref-enumeration
enum **Mode**: :ref:`🔗<enum_Window_Mode>`
.. _class_Window_constant_MODE_WINDOWED:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_Window_Mode>` **MODE_WINDOWED** = ``0``
窗口模式,即 **Window** 不占据整个屏幕(除非设置为屏幕的大小)。
.. _class_Window_constant_MODE_MINIMIZED:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_Window_Mode>` **MODE_MINIMIZED** = ``1``
最小化窗口模式,即 **Window** 在窗口管理器的窗口列表中既不可见也不可用。通常发生在按下最小化按钮时。
.. _class_Window_constant_MODE_MAXIMIZED:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_Window_Mode>` **MODE_MAXIMIZED** = ``2``
最大化窗口模式,即 **Window** 会占据整个屏幕区域,任务栏除外,并且会显示边框。通常发生在按下最大化按钮时。
.. _class_Window_constant_MODE_FULLSCREEN:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_Window_Mode>` **MODE_FULLSCREEN** = ``3``
具有完整多窗口支持的全屏模式。
全屏窗口覆盖屏幕的整个显示区域,且没有任何装饰。显示的视频模式没有更改。
\ **在 Android 上:**\ 将启用沉浸模式。
\ **在 macOS 上:**\ 使用新桌面来显示正在运行的项目。
\ **注意:**\ 无论平台如何,启用全屏都会更改窗口大小以匹配显示器的大小。因此,请确保你的项目在启用全屏模式时支持\ :doc:`多种分辨率 <../tutorials/rendering/multiple_resolutions>`\ 。
.. _class_Window_constant_MODE_EXCLUSIVE_FULLSCREEN:
.. rst-class:: classref-enumeration-constant
:ref:`Mode<enum_Window_Mode>` **MODE_EXCLUSIVE_FULLSCREEN** = ``4``
单窗口全屏模式。这种模式开销较小,但一次只能在给定屏幕上打开一个窗口(打开子窗口或切换应用程序会触发全屏过渡)。
全屏窗口会覆盖屏幕的整个显示区域,没有边框或装饰。显示视频模式没有改变。
\ **注意:**\ 该模式下录屏软件可能无法正常工作。
\ **在 Android 上:**\ 将启用沉浸模式。
\ **在 Windows 上:**\ 取决于视频驱动程序,全屏过渡可能会导致屏幕暂时变黑。
\ **在 macOS 上:**\ 一个新的桌面用于显示正在运行的项目。当鼠标指针悬停在屏幕边缘时,独占全屏模式会阻止 Dock 和 Menu 出现。
\ **在 LinuxX11**\ 独占全屏模式会绕过合成器。
\ **在 LinuxWayland**\ 等价于 :ref:`MODE_FULLSCREEN<class_Window_constant_MODE_FULLSCREEN>`\ 。
\ **注意:**\ 无论平台如何,启用全屏都会更改窗口大小以匹配显示器的大小。因此,确保你的项目在启用全屏模式时支持\ :doc:`多个分辨率 <../tutorials/rendering/multiple_resolutions>`\ 。
.. rst-class:: classref-item-separator
----
.. _enum_Window_Flags:
.. rst-class:: classref-enumeration
enum **Flags**: :ref:`🔗<enum_Window_Flags>`
.. _class_Window_constant_FLAG_RESIZE_DISABLED:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_RESIZE_DISABLED** = ``0``
该窗口不能通过拖动其调整大小的手柄来调整大小。仍然可以使用 :ref:`size<class_Window_property_size>` 来调整窗口的大小。这个标志对于全屏窗口来说是被忽略的。用 :ref:`unresizable<class_Window_property_unresizable>` 设置。
.. _class_Window_constant_FLAG_BORDERLESS:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_BORDERLESS** = ``1``
该窗口没有原生标题栏和其他装饰。全屏窗口会忽略该标志。由 :ref:`borderless<class_Window_property_borderless>` 设置。
.. _class_Window_constant_FLAG_ALWAYS_ON_TOP:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_ALWAYS_ON_TOP** = ``2``
该窗口漂浮在所有其他窗口之上。全屏窗口会忽略该标志。由 :ref:`always_on_top<class_Window_property_always_on_top>` 设置。
.. _class_Window_constant_FLAG_TRANSPARENT:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_TRANSPARENT** = ``3``
该窗口的背景可以是透明的。使用 :ref:`transparent<class_Window_property_transparent>` 设置。
\ **注意:**\ 如果 :ref:`ProjectSettings.display/window/per_pixel_transparency/allowed<class_ProjectSettings_property_display/window/per_pixel_transparency/allowed>` 或该窗口的 :ref:`Viewport.transparent_bg<class_Viewport_property_transparent_bg>```false``\ ,则这个标志无效。
.. _class_Window_constant_FLAG_NO_FOCUS:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_NO_FOCUS** = ``4``
该窗口无法被聚焦。无焦点窗口会忽略除鼠标点击之外的所有输入。由 :ref:`unfocusable<class_Window_property_unfocusable>` 设置。
.. _class_Window_constant_FLAG_POPUP:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_POPUP** = ``5``
窗口为菜单或 :ref:`OptionButton<class_OptionButton>` 下拉菜单的一部分。窗口可见时无法更改这个标志。活动的弹出窗口会以独占的形式接收所有输入,但不会从其父窗口窃取焦点。用户在区域外点击或切换应用程序时,弹出窗口会自动关闭。弹出窗口必须设置临时父级(见 :ref:`transient<class_Window_property_transient>`\ )。
\ **注意:**\ 这个标志在嵌入式窗口中无效(除非该窗口是 :ref:`Popup<class_Popup>`\ )。
.. _class_Window_constant_FLAG_EXTEND_TO_TITLE:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_EXTEND_TO_TITLE** = ``6``
窗口内容扩展到窗口的全部尺寸。与无边框窗口不同,框架保持不变,可以用来调整窗口的大小,标题栏是透明的,但有最小/最大/关闭按钮。用 :ref:`extend_to_title<class_Window_property_extend_to_title>` 设置。
\ **注意:**\ 这个标志在 macOS 上实现。
\ **注意:**\ 这个标志在嵌入式窗口中无效。
.. _class_Window_constant_FLAG_MOUSE_PASSTHROUGH:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_MOUSE_PASSTHROUGH** = ``7``
所有鼠标事件都被传递到同一应用程序的底层窗口。
\ **注意:**\ 这个标志在嵌入式窗口中无效。
.. _class_Window_constant_FLAG_SHARP_CORNERS:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_SHARP_CORNERS** = ``8``
覆盖窗口样式,强制尖角。
\ **注意:**\ 该标志对嵌入式窗口无效。
\ **注意:**\ 该标志仅在 Windows11上实现。
.. _class_Window_constant_FLAG_EXCLUDE_FROM_CAPTURE:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_EXCLUDE_FROM_CAPTURE** = ``9``
:ref:`DisplayServer.screen_get_image()<class_DisplayServer_method_screen_get_image>`\ 、\ :ref:`DisplayServer.screen_get_image_rect()<class_DisplayServer_method_screen_get_image_rect>`:ref:`DisplayServer.screen_get_pixel()<class_DisplayServer_method_screen_get_pixel>` 的截图中排除该窗口。
\ **注意:**\ 该标志对嵌入式窗口无效。
\ **注意:**\ 该标志在 macOS 和 Windows10、20H1上实现。
\ **注意:**\ 设置该标志会阻止标准截屏方法捕获到窗口图像,但\ **无法**\ 保证其他应用无法捕获图像。不应用作 DRM 和安全措施。
.. _class_Window_constant_FLAG_POPUP_WM_HINT:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_POPUP_WM_HINT** = ``10``
向窗口管理器发出信号,表明该窗口应该是实现定义的“弹出窗口” (通常是浮动、无边框、不可平铺且不可移动的子窗口)。
.. _class_Window_constant_FLAG_MINIMIZE_DISABLED:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_MINIMIZE_DISABLED** = ``11``
禁用窗口的最小化按钮。
\ **注意:**\ 该标志在 macOS 和 Windows 上实现。
.. _class_Window_constant_FLAG_MAXIMIZE_DISABLED:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_MAXIMIZE_DISABLED** = ``12``
禁用窗口的最大化按钮。
\ **注意:**\ 该标志在 macOS 和 Windows 上实现。
.. _class_Window_constant_FLAG_MAX:
.. rst-class:: classref-enumeration-constant
:ref:`Flags<enum_Window_Flags>` **FLAG_MAX** = ``13``
:ref:`Flags<enum_Window_Flags>` 的最大值。
.. rst-class:: classref-item-separator
----
.. _enum_Window_ContentScaleMode:
.. rst-class:: classref-enumeration
enum **ContentScaleMode**: :ref:`🔗<enum_Window_ContentScaleMode>`
.. _class_Window_constant_CONTENT_SCALE_MODE_DISABLED:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleMode<enum_Window_ContentScaleMode>` **CONTENT_SCALE_MODE_DISABLED** = ``0``
不会为了匹配 **Window** 的大小而对内容进行缩放。
.. _class_Window_constant_CONTENT_SCALE_MODE_CANVAS_ITEMS:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleMode<enum_Window_ContentScaleMode>` **CONTENT_SCALE_MODE_CANVAS_ITEMS** = ``1``
会将内容按照目标大小渲染。比 :ref:`CONTENT_SCALE_MODE_VIEWPORT<class_Window_constant_CONTENT_SCALE_MODE_VIEWPORT>` 更消耗性能,但结果更佳。
.. _class_Window_constant_CONTENT_SCALE_MODE_VIEWPORT:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleMode<enum_Window_ContentScaleMode>` **CONTENT_SCALE_MODE_VIEWPORT** = ``2``
会将内容按照原始大小渲染,然后再缩放到目标大小。比 :ref:`CONTENT_SCALE_MODE_CANVAS_ITEMS<class_Window_constant_CONTENT_SCALE_MODE_CANVAS_ITEMS>` 性能更高,但会导致图像的像素化。
.. rst-class:: classref-item-separator
----
.. _enum_Window_ContentScaleAspect:
.. rst-class:: classref-enumeration
enum **ContentScaleAspect**: :ref:`🔗<enum_Window_ContentScaleAspect>`
.. _class_Window_constant_CONTENT_SCALE_ASPECT_IGNORE:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **CONTENT_SCALE_ASPECT_IGNORE** = ``0``
会忽略纵横比。缩放就是简单地将内容拉伸至目标大小。
.. _class_Window_constant_CONTENT_SCALE_ASPECT_KEEP:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **CONTENT_SCALE_ASPECT_KEEP** = ``1``
会保留内容的纵横比。如果目标大小与原始大小的纵横比不同,则会将图像居中,左右两侧会出现黑条。
.. _class_Window_constant_CONTENT_SCALE_ASPECT_KEEP_WIDTH:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **CONTENT_SCALE_ASPECT_KEEP_WIDTH** = ``2``
内容可以垂直扩展。横向缩放时,会保留宽度比,在左右两侧添加黑条。
.. _class_Window_constant_CONTENT_SCALE_ASPECT_KEEP_HEIGHT:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **CONTENT_SCALE_ASPECT_KEEP_HEIGHT** = ``3``
内容可以水平扩展。纵向缩放时,会保留高度比,在上下两侧添加黑条。
.. _class_Window_constant_CONTENT_SCALE_ASPECT_EXPAND:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **CONTENT_SCALE_ASPECT_EXPAND** = ``4``
会保留内容的纵横比。如果目标大小与原始大小的纵横比不同,则内容会保持在左上角,将拉伸出的空间增加为可见区域。
.. rst-class:: classref-item-separator
----
.. _enum_Window_ContentScaleStretch:
.. rst-class:: classref-enumeration
enum **ContentScaleStretch**: :ref:`🔗<enum_Window_ContentScaleStretch>`
.. _class_Window_constant_CONTENT_SCALE_STRETCH_FRACTIONAL:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>` **CONTENT_SCALE_STRETCH_FRACTIONAL** = ``0``
内容会根据小数系数进行拉伸。这样就能够填充窗口的所有空间,但非整数的像素缩放会导致发生“像素摆动”。
.. _class_Window_constant_CONTENT_SCALE_STRETCH_INTEGER:
.. rst-class:: classref-enumeration-constant
:ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>` **CONTENT_SCALE_STRETCH_INTEGER** = ``1``
内容只会根据整数系数进行拉伸,保持像素的锐利。可能导致窗口的边缘留出可见的黑色背景,具体取决于窗口大小。
.. rst-class:: classref-item-separator
----
.. _enum_Window_LayoutDirection:
.. rst-class:: classref-enumeration
enum **LayoutDirection**: :ref:`🔗<enum_Window_LayoutDirection>`
.. _class_Window_constant_LAYOUT_DIRECTION_INHERITED:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_INHERITED** = ``0``
自动布局方向,由父窗口的布局方向决定。
.. _class_Window_constant_LAYOUT_DIRECTION_APPLICATION_LOCALE:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_APPLICATION_LOCALE** = ``1``
自动布局方向,根据当前区域设置确定。
.. _class_Window_constant_LAYOUT_DIRECTION_LTR:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_LTR** = ``2``
从左至右的排版方向。
.. _class_Window_constant_LAYOUT_DIRECTION_RTL:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_RTL** = ``3``
从右至左的排版方向。
.. _class_Window_constant_LAYOUT_DIRECTION_SYSTEM_LOCALE:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_SYSTEM_LOCALE** = ``4``
自动布局方向,根据系统区域设置确定。
.. _class_Window_constant_LAYOUT_DIRECTION_MAX:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_MAX** = ``5``
代表 :ref:`LayoutDirection<enum_Window_LayoutDirection>` 枚举的大小。
.. _class_Window_constant_LAYOUT_DIRECTION_LOCALE:
.. rst-class:: classref-enumeration-constant
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **LAYOUT_DIRECTION_LOCALE** = ``1``
**已弃用:** Use :ref:`LAYOUT_DIRECTION_APPLICATION_LOCALE<class_Window_constant_LAYOUT_DIRECTION_APPLICATION_LOCALE>` instead.
.. rst-class:: classref-item-separator
----
.. _enum_Window_WindowInitialPosition:
.. rst-class:: classref-enumeration
enum **WindowInitialPosition**: :ref:`🔗<enum_Window_WindowInitialPosition>`
.. _class_Window_constant_WINDOW_INITIAL_POSITION_ABSOLUTE:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_ABSOLUTE** = ``0``
初始窗口位置由 :ref:`position<class_Window_property_position>` 决定。
.. _class_Window_constant_WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN** = ``1``
初始窗口位置为主屏幕的中心。
.. _class_Window_constant_WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN** = ``2``
初始窗口位置为主窗口屏幕的中心。
.. _class_Window_constant_WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN** = ``3``
初始窗口位置为 :ref:`current_screen<class_Window_property_current_screen>` 屏幕的中心。
.. _class_Window_constant_WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS** = ``4``
初始窗口位置为鼠标指针所在屏幕的中心。
.. _class_Window_constant_WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS:
.. rst-class:: classref-enumeration-constant
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS** = ``5``
初始窗口位置为键盘聚焦的窗口所在屏幕的中心。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
常量
----
.. _class_Window_constant_NOTIFICATION_VISIBILITY_CHANGED:
.. rst-class:: classref-constant
**NOTIFICATION_VISIBILITY_CHANGED** = ``30`` :ref:`🔗<class_Window_constant_NOTIFICATION_VISIBILITY_CHANGED>`
**Window** 的可见性发生改变时,在 :ref:`visibility_changed<class_Window_signal_visibility_changed>` 之前发出。
.. _class_Window_constant_NOTIFICATION_THEME_CHANGED:
.. rst-class:: classref-constant
**NOTIFICATION_THEME_CHANGED** = ``32`` :ref:`🔗<class_Window_constant_NOTIFICATION_THEME_CHANGED>`
当节点需要刷新其主题项时发送。以下任意情况都会触发:
- 此节点或其任何祖先节点更改了 :ref:`theme<class_Window_property_theme>` 属性。
- 此节点更改了 :ref:`theme_type_variation<class_Window_property_theme_type_variation>` 属性。
- 节点进入场景树。
\ **注意:**\ 为了优化性能,此节点在场景树之外发生更改时不会发送此通知。取而代之的是,当节点进入场景树时会统一应用所有主题项的更新。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
属性说明
--------
.. _class_Window_property_accessibility_description:
.. rst-class:: classref-property
:ref:`String<class_String>` **accessibility_description** = ``""`` :ref:`🔗<class_Window_property_accessibility_description>`
.. rst-class:: classref-property-setget
- |void| **set_accessibility_description**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_accessibility_description**\ (\ )
报告给辅助应用的人类可读节点描述。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_accessibility_name:
.. rst-class:: classref-property
:ref:`String<class_String>` **accessibility_name** = ``""`` :ref:`🔗<class_Window_property_accessibility_name>`
.. rst-class:: classref-property-setget
- |void| **set_accessibility_name**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_accessibility_name**\ (\ )
报告给辅助应用的人类可读节点名称。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_always_on_top:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **always_on_top** = ``false`` :ref:`🔗<class_Window_property_always_on_top>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则该窗口将位于所有其他窗口的顶部。如果启用了 :ref:`transient<class_Window_property_transient>` 则不起作用。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_auto_translate:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **auto_translate** :ref:`🔗<class_Window_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>` and :ref:`Node.can_auto_translate()<class_Node_method_can_auto_translate>` instead.
切换是否所有文本都应该根据当前区域设置自动变为翻译后的版本。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_borderless:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **borderless** = ``false`` :ref:`🔗<class_Window_property_borderless>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则该窗口将没有边框。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_content_scale_aspect:
.. rst-class:: classref-property
:ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **content_scale_aspect** = ``0`` :ref:`🔗<class_Window_property_content_scale_aspect>`
.. rst-class:: classref-property-setget
- |void| **set_content_scale_aspect**\ (\ value\: :ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>`\ )
- :ref:`ContentScaleAspect<enum_Window_ContentScaleAspect>` **get_content_scale_aspect**\ (\ )
指定当 **Window** 的大小改变时,内容纵横比的行为。基础纵横比由 :ref:`content_scale_size<class_Window_property_content_scale_size>` 决定。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_content_scale_factor:
.. rst-class:: classref-property
:ref:`float<class_float>` **content_scale_factor** = ``1.0`` :ref:`🔗<class_Window_property_content_scale_factor>`
.. rst-class:: classref-property-setget
- |void| **set_content_scale_factor**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_content_scale_factor**\ (\ )
指定当 :ref:`size<class_Window_property_size>` 等于 :ref:`content_scale_size<class_Window_property_content_scale_size>`**Window** 内容的基础比例。另见 :ref:`Viewport.get_stretch_transform()<class_Viewport_method_get_stretch_transform>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_content_scale_mode:
.. rst-class:: classref-property
:ref:`ContentScaleMode<enum_Window_ContentScaleMode>` **content_scale_mode** = ``0`` :ref:`🔗<class_Window_property_content_scale_mode>`
.. rst-class:: classref-property-setget
- |void| **set_content_scale_mode**\ (\ value\: :ref:`ContentScaleMode<enum_Window_ContentScaleMode>`\ )
- :ref:`ContentScaleMode<enum_Window_ContentScaleMode>` **get_content_scale_mode**\ (\ )
指定当 **Window** 的大小改变时,如何对内容进行缩放。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_content_scale_size:
.. rst-class:: classref-property
:ref:`Vector2i<class_Vector2i>` **content_scale_size** = ``Vector2i(0, 0)`` :ref:`🔗<class_Window_property_content_scale_size>`
.. rst-class:: classref-property-setget
- |void| **set_content_scale_size**\ (\ value\: :ref:`Vector2i<class_Vector2i>`\ )
- :ref:`Vector2i<class_Vector2i>` **get_content_scale_size**\ (\ )
内容的基础大小(内容指在窗口内绘制的节点)。如果非零,当窗口大小发生变化时,\ **Window** 的内容将被缩放。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_content_scale_stretch:
.. rst-class:: classref-property
:ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>` **content_scale_stretch** = ``0`` :ref:`🔗<class_Window_property_content_scale_stretch>`
.. rst-class:: classref-property-setget
- |void| **set_content_scale_stretch**\ (\ value\: :ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>`\ )
- :ref:`ContentScaleStretch<enum_Window_ContentScaleStretch>` **get_content_scale_stretch**\ (\ )
决定 2D 元素最终缩放系数的策略。会影响 :ref:`content_scale_factor<class_Window_property_content_scale_factor>` 的使用,与 :ref:`content_scale_size<class_Window_property_content_scale_size>` 决定的自动缩放系数共同生效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_current_screen:
.. rst-class:: classref-property
:ref:`int<class_int>` **current_screen** :ref:`🔗<class_Window_property_current_screen>`
.. rst-class:: classref-property-setget
- |void| **set_current_screen**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_current_screen**\ (\ )
该窗口当前所在的屏幕。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_exclude_from_capture:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **exclude_from_capture** = ``false`` :ref:`🔗<class_Window_property_exclude_from_capture>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则会在 :ref:`DisplayServer.screen_get_image()<class_DisplayServer_method_screen_get_image>`\ 、\ :ref:`DisplayServer.screen_get_image_rect()<class_DisplayServer_method_screen_get_image_rect>`\ 、\ :ref:`DisplayServer.screen_get_pixel()<class_DisplayServer_method_screen_get_pixel>` 的截图中排除该 **Window**\ 。
\ **注意:**\ 该属性在 macOS 和 Windows 上实现。
\ **注意:**\ 设置该标志会阻止标准截屏方法捕获到窗口图像,但\ **无法**\ 保证其他应用无法捕获图像。不应用作 DRM 和安全措施。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_exclusive:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **exclusive** = ``false`` :ref:`🔗<class_Window_property_exclusive>`
.. rst-class:: classref-property-setget
- |void| **set_exclusive**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_exclusive**\ (\ )
如果为 ``true``\ ,则 **Window** 将处于独占模式。独占窗口总是在其父窗口的顶部,会阻止所有输入到达父级 **Window**\ 。
需要启用 :ref:`transient<class_Window_property_transient>` 才能正常工作。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_extend_to_title:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **extend_to_title** = ``false`` :ref:`🔗<class_Window_property_extend_to_title>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则 **Window** 的内容将会扩展到窗口的完整大小,窗口标题栏是透明的。
\ **注意:**\ 这个属性仅在 macOS 上实现。
\ **注意:**\ 这个属性仅对原生窗口有效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_force_native:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **force_native** = ``false`` :ref:`🔗<class_Window_property_force_native>`
.. rst-class:: classref-property-setget
- |void| **set_force_native**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_force_native**\ (\ )
如果为 ``true``\ ,则无论父视口及项目设置如何都会使用原生窗口。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_initial_position:
.. rst-class:: classref-property
:ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **initial_position** = ``0`` :ref:`🔗<class_Window_property_initial_position>`
.. rst-class:: classref-property-setget
- |void| **set_initial_position**\ (\ value\: :ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>`\ )
- :ref:`WindowInitialPosition<enum_Window_WindowInitialPosition>` **get_initial_position**\ (\ )
指定该 **Window** 的初始位置类型。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_keep_title_visible:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **keep_title_visible** = ``false`` :ref:`🔗<class_Window_property_keep_title_visible>`
.. rst-class:: classref-property-setget
- |void| **set_keep_title_visible**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_keep_title_visible**\ (\ )
如果为 ``true``\ ,则该 **Window** 宽度被扩展以保持标题栏文本完全可见。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_max_size:
.. rst-class:: classref-property
:ref:`Vector2i<class_Vector2i>` **max_size** = ``Vector2i(0, 0)`` :ref:`🔗<class_Window_property_max_size>`
.. rst-class:: classref-property-setget
- |void| **set_max_size**\ (\ value\: :ref:`Vector2i<class_Vector2i>`\ )
- :ref:`Vector2i<class_Vector2i>` **get_max_size**\ (\ )
如果非零,则调整该 **Window** 的大小时无法大于该尺寸。
\ **注意:**\ 如果值小于 :ref:`min_size<class_Window_property_min_size>`\ ,该属性将被忽略。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_maximize_disabled:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **maximize_disabled** = ``false`` :ref:`🔗<class_Window_property_maximize_disabled>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则禁用该 **Window** 的最大化按钮。
\ **注意:**\ 如果最小化和最大化按钮都被禁用,则这两个按钮将完全隐藏,仅显示关闭按钮。
\ **注意:**\ 该属性仅在 macOS 和 Windows 上实现。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_min_size:
.. rst-class:: classref-property
:ref:`Vector2i<class_Vector2i>` **min_size** = ``Vector2i(0, 0)`` :ref:`🔗<class_Window_property_min_size>`
.. rst-class:: classref-property-setget
- |void| **set_min_size**\ (\ value\: :ref:`Vector2i<class_Vector2i>`\ )
- :ref:`Vector2i<class_Vector2i>` **get_min_size**\ (\ )
如果非零,则调整该 **Window** 的大小时无法小于该尺寸。
\ **注意:**\ 如果启用了 :ref:`wrap_controls<class_Window_property_wrap_controls>` 并且 :ref:`get_contents_minimum_size()<class_Window_method_get_contents_minimum_size>` 更大,则此属性将被忽略。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_minimize_disabled:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **minimize_disabled** = ``false`` :ref:`🔗<class_Window_property_minimize_disabled>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则禁用该 **Window** 的最小化按钮。
\ **注意:**\ 如果最小化和最大化按钮都被禁用,则这两个按钮将完全隐藏,仅显示关闭按钮。
\ **注意:**\ 该属性仅在 macOS 和 Windows 上实现。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_mode:
.. rst-class:: classref-property
:ref:`Mode<enum_Window_Mode>` **mode** = ``0`` :ref:`🔗<class_Window_property_mode>`
.. rst-class:: classref-property-setget
- |void| **set_mode**\ (\ value\: :ref:`Mode<enum_Window_Mode>`\ )
- :ref:`Mode<enum_Window_Mode>` **get_mode**\ (\ )
设置该窗口的当前模式。
\ **注意:**\ 在 Windows 和 Linux 上,全屏与独占全屏是不同的模式。
\ **注意:**\ 这个方法仅对原生窗口有效,即主窗口和禁用主视口 :ref:`Viewport.gui_embed_subwindows<class_Viewport_property_gui_embed_subwindows>` 时的 **Window** 派生节点。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_mouse_passthrough:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **mouse_passthrough** = ``false`` :ref:`🔗<class_Window_property_mouse_passthrough>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则所有鼠标事件都会传递给同一应用的底层窗口。另见 :ref:`mouse_passthrough_polygon<class_Window_property_mouse_passthrough_polygon>`\ 。
\ **注意:**\ 这个属性在 LinuxX11、macOS 和 Windows 上实现。
\ **注意:**\ 这个属性仅对原生窗口有效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_mouse_passthrough_polygon:
.. rst-class:: classref-property
:ref:`PackedVector2Array<class_PackedVector2Array>` **mouse_passthrough_polygon** = ``PackedVector2Array()`` :ref:`🔗<class_Window_property_mouse_passthrough_polygon>`
.. rst-class:: classref-property-setget
- |void| **set_mouse_passthrough_polygon**\ (\ value\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ )
- :ref:`PackedVector2Array<class_PackedVector2Array>` **get_mouse_passthrough_polygon**\ (\ )
设置窗口的一个接受鼠标事件的多边形区域。该区域外的鼠标事件将被传递出去。
传递一个空数组将禁用穿透支持(所有鼠标事件将被窗口拦截,这是默认行为)。
.. tabs::
.. code-tab:: gdscript
# 设置区域,使用 Path2D 节点。
$Window.mouse_passthrough_polygon = $Path2D.curve.get_baked_points()
# 设置区域,使用 Polygon2D 节点。
$Window.mouse_passthrough_polygon = $Polygon2D.polygon
# 重置区域为默认值。
$Window.mouse_passthrough_polygon = []
.. code-tab:: csharp
// 设置区域,使用 Path2D 节点。
GetNode<Window>("Window").MousePassthroughPolygon = GetNode<Path2D>("Path2D").Curve.GetBakedPoints();
// 设置区域,使用 Polygon2D 节点。
GetNode<Window>("Window").MousePassthroughPolygon = GetNode<Polygon2D>("Polygon2D").Polygon;
// 重置区域为默认值。
GetNode<Window>("Window").MousePassthroughPolygon = [];
\ **注意:**\ 如果 :ref:`mouse_passthrough<class_Window_property_mouse_passthrough>` 设置为 ``true``\ ,则忽略此属性。
\ **注意:**\ 在 Windows 上,位于区域外的窗口部分不会被绘制,而在 Linux (X11) 和 macOS 上则会被绘制。
\ **注意:**\ 该属性在 Linux (X11)、macOS 和 Windows 上实现。
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedVector2Array<class_PackedVector2Array>` for more details.
.. rst-class:: classref-item-separator
----
.. _class_Window_property_nonclient_area:
.. rst-class:: classref-property
:ref:`Rect2i<class_Rect2i>` **nonclient_area** = ``Rect2i(0, 0, 0, 0)`` :ref:`🔗<class_Window_property_nonclient_area>`
.. rst-class:: classref-property-setget
- |void| **set_nonclient_area**\ (\ value\: :ref:`Rect2i<class_Rect2i>`\ )
- :ref:`Rect2i<class_Rect2i>` **get_nonclient_area**\ (\ )
If set, defines the window's custom decoration area which will receive mouse input, even if normal input to the window is blocked (such as when it has an exclusive child opened). See also :ref:`nonclient_window_input<class_Window_signal_nonclient_window_input>`.
.. rst-class:: classref-item-separator
----
.. _class_Window_property_popup_window:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **popup_window** = ``false`` :ref:`🔗<class_Window_property_popup_window>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则该 **Window** 将被视为弹出窗口。弹出窗口是子窗口,不会在系统窗口管理器的窗口列表中显示为单独的窗口,并且会在单击它们之外的任何位置时发送关闭请求(除非启用了 :ref:`exclusive<class_Window_property_exclusive>`\ )。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_popup_wm_hint:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **popup_wm_hint** = ``false`` :ref:`🔗<class_Window_property_popup_wm_hint>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则 **Window** 会向窗口管理器发出信号,告知该窗口应为实现定义的“弹出窗口”(通常是悬浮、无边框、无法平铺、无法移动的子窗口)。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_position:
.. rst-class:: classref-property
:ref:`Vector2i<class_Vector2i>` **position** = ``Vector2i(0, 0)`` :ref:`🔗<class_Window_property_position>`
.. rst-class:: classref-property-setget
- |void| **set_position**\ (\ value\: :ref:`Vector2i<class_Vector2i>`\ )
- :ref:`Vector2i<class_Vector2i>` **get_position**\ (\ )
该窗口的位置,单位为像素。
如果 :ref:`ProjectSettings.display/window/subwindows/embed_subwindows<class_ProjectSettings_property_display/window/subwindows/embed_subwindows>```false``\ ,则该位置使用屏幕绝对坐标。通常适用于编辑器插件。如果该设置项为 ``true``\ ,则该窗口的位置使用其父 :ref:`Viewport<class_Viewport>` 中的坐标。
\ **注意:**\ 这个属性仅在 :ref:`initial_position<class_Window_property_initial_position>` 为 :ref:`WINDOW_INITIAL_POSITION_ABSOLUTE<class_Window_constant_WINDOW_INITIAL_POSITION_ABSOLUTE>` 时有效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_sharp_corners:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **sharp_corners** = ``false`` :ref:`🔗<class_Window_property_sharp_corners>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则 **Window** 会覆盖操作系统窗口样式,显示尖角。
\ **注意:**\ 这个属性仅在 Windows11上实现。
\ **注意:**\ 这个属性仅对原生窗口有效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_size:
.. rst-class:: classref-property
:ref:`Vector2i<class_Vector2i>` **size** = ``Vector2i(100, 100)`` :ref:`🔗<class_Window_property_size>`
.. rst-class:: classref-property-setget
- |void| **set_size**\ (\ value\: :ref:`Vector2i<class_Vector2i>`\ )
- :ref:`Vector2i<class_Vector2i>` **get_size**\ (\ )
该窗口的大小,单位为像素。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_theme:
.. rst-class:: classref-property
:ref:`Theme<class_Theme>` **theme** :ref:`🔗<class_Window_property_theme>`
.. rst-class:: classref-property-setget
- |void| **set_theme**\ (\ value\: :ref:`Theme<class_Theme>`\ )
- :ref:`Theme<class_Theme>` **get_theme**\ (\ )
该节点及其子 :ref:`Control<class_Control>`**Window** 所使用的 :ref:`Theme<class_Theme>` 资源。如果子节点也设置了 :ref:`Theme<class_Theme>` 资源,则会合并主题项,子节点的定义优先级更高。
\ **注意:**\ 除非 **Window** 为嵌入式,否则窗口样式无效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_theme_type_variation:
.. rst-class:: classref-property
:ref:`StringName<class_StringName>` **theme_type_variation** = ``&""`` :ref:`🔗<class_Window_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**\ (\ )
**Window** 用于查找其自己的主题项目的主题类型变体的名称。详见 :ref:`Control.theme_type_variation<class_Control_property_theme_type_variation>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_title:
.. rst-class:: classref-property
:ref:`String<class_String>` **title** = ``""`` :ref:`🔗<class_Window_property_title>`
.. rst-class:: classref-property-setget
- |void| **set_title**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_title**\ (\ )
该窗口的标题。如果 **Window** 是原生的,则 :ref:`Theme<class_Theme>` 中设置的标题样式无效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_transient:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **transient** = ``false`` :ref:`🔗<class_Window_property_transient>`
.. rst-class:: classref-property-setget
- |void| **set_transient**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_transient**\ (\ )
如果为 ``true`` 则该 **Window** 是临时窗口,即会被认为是另一个 **Window** 的子级。临时窗口会和临时父级一起销毁,关闭时会将焦点返还给父级。临时窗口显示在非独占全屏父窗口之上。临时窗口无法进入全屏模式。
请注意,不同平台可能由不同的行为。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_transient_to_focused:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **transient_to_focused** = ``false`` :ref:`🔗<class_Window_property_transient_to_focused>`
.. rst-class:: classref-property-setget
- |void| **set_transient_to_focused**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_transient_to_focused**\ (\ )
如果为 ``true`` 并且 **Window** 启用了 :ref:`transient<class_Window_property_transient>`\ ,则该窗口(在变为可见时)会变为当前聚焦窗口的临时窗口,而不是层级结构中直接父窗口的临时窗口。请注意,临时父级是在窗口变为可见时赋值的,所以如果在显示之后进行更改,则需要等到再次显示才会生效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_transparent:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **transparent** = ``false`` :ref:`🔗<class_Window_property_transparent>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则 **Window** 的背景可以是透明的。最好用在嵌入式窗口中。
\ **注意:**\ 透明度支持已在 Linux、macOS 和 Windows 上实现,但可用性可能因 GPU 驱动程序、显示管理器和合成器的能力而异。
\ **注意:**\ 如果 :ref:`ProjectSettings.display/window/per_pixel_transparency/allowed<class_ProjectSettings_property_display/window/per_pixel_transparency/allowed>` 被设置为 ``false``\ ,则这个属性无效。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_unfocusable:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **unfocusable** = ``false`` :ref:`🔗<class_Window_property_unfocusable>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则该 **Window** 既无法聚焦也无法交互,但仍然可见。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_unresizable:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **unresizable** = ``false`` :ref:`🔗<class_Window_property_unresizable>`
.. rst-class:: classref-property-setget
- |void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const|
如果为 ``true``\ ,则窗口无法调整大小。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_visible:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **visible** = ``true`` :ref:`🔗<class_Window_property_visible>`
.. rst-class:: classref-property-setget
- |void| **set_visible**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_visible**\ (\ )
如果为 ``true``\ ,则窗口可见。
.. rst-class:: classref-item-separator
----
.. _class_Window_property_wrap_controls:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **wrap_controls** = ``false`` :ref:`🔗<class_Window_property_wrap_controls>`
.. rst-class:: classref-property-setget
- |void| **set_wrap_controls**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_wrapping_controls**\ (\ )
如果为 ``true``\ ,则添加或删除子节点时,窗口的大小会自动更新,新的大小更大时会忽略 :ref:`min_size<class_Window_property_min_size>`\ 。
如果为 ``false``\ ,则需要手动调用 :ref:`child_controls_changed()<class_Window_method_child_controls_changed>`\ 。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _class_Window_private_method__get_contents_minimum_size:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **_get_contents_minimum_size**\ (\ ) |virtual| |const| :ref:`🔗<class_Window_private_method__get_contents_minimum_size>`
需要用户实现的虚方法。能够覆盖 :ref:`get_contents_minimum_size()<class_Window_method_get_contents_minimum_size>` 的返回值。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_color_override>`
为名为 ``name`` 的主题 :ref:`Color<class_Color>` 创建本地覆盖项。为控件获取主题时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_color_override()<class_Window_method_remove_theme_color_override>` 移除。
详见 :ref:`get_theme_color()<class_Window_method_get_theme_color>`:ref:`Control.add_theme_color_override()<class_Control_method_add_theme_color_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_constant_override>`
为名称为 ``name`` 的主题常量创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_constant_override()<class_Window_method_remove_theme_constant_override>` 移除。
另见 :ref:`get_theme_constant()<class_Window_method_get_theme_constant>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_font_override>`
为名称为 ``name`` 的主题 :ref:`Font<class_Font>` 创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_font_override()<class_Window_method_remove_theme_font_override>` 移除。
另见 :ref:`get_theme_font()<class_Window_method_get_theme_font>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_font_size_override>`
为名称为 ``name`` 的主题字体大小创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_font_size_override()<class_Window_method_remove_theme_font_size_override>` 移除。
另见 :ref:`get_theme_font_size()<class_Window_method_get_theme_font_size>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_icon_override>`
为名称为 ``name`` 的主题图标创建本地覆盖项。为控件获取主题项目时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_icon_override()<class_Window_method_remove_theme_icon_override>` 移除。
另见 :ref:`get_theme_icon()<class_Window_method_get_theme_icon>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_add_theme_stylebox_override>`
为名为 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 创建本地覆盖项。为控件获取主题时,本地覆盖项始终优先。覆盖项可以使用 :ref:`remove_theme_stylebox_override()<class_Window_method_remove_theme_stylebox_override>` 移除。
详见 :ref:`get_theme_stylebox()<class_Window_method_get_theme_stylebox>`:ref:`Control.add_theme_stylebox_override()<class_Control_method_add_theme_stylebox_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_begin_bulk_theme_override:
.. rst-class:: classref-method
|void| **begin_bulk_theme_override**\ (\ ) :ref:`🔗<class_Window_method_begin_bulk_theme_override>`
防止 ``*_theme_*_override`` 方法发出 :ref:`NOTIFICATION_THEME_CHANGED<class_Window_constant_NOTIFICATION_THEME_CHANGED>`\ ,直到 :ref:`end_bulk_theme_override()<class_Window_method_end_bulk_theme_override>` 被调用。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_can_draw:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **can_draw**\ (\ ) |const| :ref:`🔗<class_Window_method_can_draw>`
返回该窗口是否正在被绘制到屏幕上。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_child_controls_changed:
.. rst-class:: classref-method
|void| **child_controls_changed**\ (\ ) :ref:`🔗<class_Window_method_child_controls_changed>`
请求更新 **Window** 大小以适应底层 :ref:`Control<class_Control>` 节点。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_end_bulk_theme_override:
.. rst-class:: classref-method
|void| **end_bulk_theme_override**\ (\ ) :ref:`🔗<class_Window_method_end_bulk_theme_override>`
结束批量主题覆盖更新。见 :ref:`begin_bulk_theme_override()<class_Window_method_begin_bulk_theme_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_contents_minimum_size:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **get_contents_minimum_size**\ (\ ) |const| :ref:`🔗<class_Window_method_get_contents_minimum_size>`
返回该窗口子 :ref:`Control<class_Control>` 节点合并最小大小。请在子节点发生改变时使用 :ref:`child_controls_changed()<class_Window_method_child_controls_changed>` 进行更新。
这个方法的返回值可以使用 :ref:`_get_contents_minimum_size()<class_Window_private_method__get_contents_minimum_size>` 覆盖。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_flag:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **get_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`\ ) |const| :ref:`🔗<class_Window_method_get_flag>`
如果设置了标志 ``flag``\ ,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_focused_window:
.. rst-class:: classref-method
:ref:`Window<class_Window>` **get_focused_window**\ (\ ) |static| :ref:`🔗<class_Window_method_get_focused_window>`
返回聚焦窗口。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_layout_direction:
.. rst-class:: classref-method
:ref:`LayoutDirection<enum_Window_LayoutDirection>` **get_layout_direction**\ (\ ) |const| :ref:`🔗<class_Window_method_get_layout_direction>`
返回排版方向和文本书写方向。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_position_with_decorations:
.. rst-class:: classref-method
:ref:`Vector2i<class_Vector2i>` **get_position_with_decorations**\ (\ ) |const| :ref:`🔗<class_Window_method_get_position_with_decorations>`
返回该窗口的位置,包括边框。
\ **注意:**\ 如果 :ref:`visible<class_Window_property_visible>```false``\ ,则该方法返回的位置与 :ref:`position<class_Window_property_position>` 一致。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_size_with_decorations:
.. rst-class:: classref-method
:ref:`Vector2i<class_Vector2i>` **get_size_with_decorations**\ (\ ) |const| :ref:`🔗<class_Window_method_get_size_with_decorations>`
返回该窗口的大小,包括边框。
\ **注意:**\ 如果 :ref:`visible<class_Window_property_visible>```false``\ ,则该方法返回的大小与 :ref:`size<class_Window_property_size>` 一致。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_color>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回 :ref:`Color<class_Color>`\ ,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的颜色项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_constant>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回常量,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的常量项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_theme_default_base_scale:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_theme_default_base_scale**\ (\ ) |const| :ref:`🔗<class_Window_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:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_theme_default_font:
.. rst-class:: classref-method
:ref:`Font<class_Font>` **get_theme_default_font**\ (\ ) |const| :ref:`🔗<class_Window_method_get_theme_default_font>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回默认字体,该 :ref:`Theme<class_Theme>` 中需要具有有效的 :ref:`Theme.default_font<class_Theme_property_default_font>` 值。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_theme_default_font_size:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_theme_default_font_size**\ (\ ) |const| :ref:`🔗<class_Window_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:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_font>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回 :ref:`Font<class_Font>`\ ,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的字体项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_font_size>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回字体大小,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的字体大小项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_icon>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回图标,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的图标项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_get_theme_stylebox>`
从树中第一个匹配的 :ref:`Theme<class_Theme>` 中返回 :ref:`StyleBox<class_StyleBox>`\ ,该 :ref:`Theme<class_Theme>` 中需要有名称为 ``name`` 类型为 ``theme_type`` 的样式盒项目。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_get_window_id:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_window_id**\ (\ ) |const| :ref:`🔗<class_Window_method_get_window_id>`
返回该窗口的 ID。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_grab_focus:
.. rst-class:: classref-method
|void| **grab_focus**\ (\ ) :ref:`🔗<class_Window_method_grab_focus>`
使该窗口获得焦点,从而接收用户输入。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_has_focus:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **has_focus**\ (\ ) |const| :ref:`🔗<class_Window_method_has_focus>`
如果该窗口已获得焦点,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_color>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的颜色项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_color_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题 :ref:`Color<class_Color>` 本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_color_override()<class_Window_method_add_theme_color_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_constant>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的常量项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_constant_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题常量本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_constant_override()<class_Window_method_add_theme_constant_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_font>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的字体项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_font_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题 :ref:`Font<class_Font>` 本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_font_override()<class_Window_method_add_theme_font_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_font_size>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的字体大小项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_font_size_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题字体大小本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_font_size_override()<class_Window_method_add_theme_font_size_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_icon>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的图标项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_icon_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题图标本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_icon_override()<class_Window_method_add_theme_icon_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_stylebox>`
如果树中存在匹配的 :ref:`Theme<class_Theme>`\ ,具有指定名称 ``name`` 和主题类型 ``theme_type`` 的样式盒项,则返回 ``true``\ 。
详见 :ref:`Control.get_theme_color()<class_Control_method_get_theme_color>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_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_Window_method_has_theme_stylebox_override>`
如果该 :ref:`Control<class_Control>` 节点中存在名为指定 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 本地覆盖项,则返回 ``true``\ 。
详见 :ref:`add_theme_stylebox_override()<class_Window_method_add_theme_stylebox_override>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_hide:
.. rst-class:: classref-method
|void| **hide**\ (\ ) :ref:`🔗<class_Window_method_hide>`
隐藏该窗口。与最小化状态不同。隐藏窗口无法进行交互,需要用 :ref:`show()<class_Window_method_show>` 显示。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_is_embedded:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_embedded**\ (\ ) |const| :ref:`🔗<class_Window_method_is_embedded>`
如果该窗口当前嵌入在其他窗口中,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_is_layout_rtl:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_layout_rtl**\ (\ ) |const| :ref:`🔗<class_Window_method_is_layout_rtl>`
如果布局是从右至左的,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_is_maximize_allowed:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_maximize_allowed**\ (\ ) |const| :ref:`🔗<class_Window_method_is_maximize_allowed>`
如果该窗口可以最大化(启用了最大化按钮),则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_is_using_font_oversampling:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_using_font_oversampling**\ (\ ) |const| :ref:`🔗<class_Window_method_is_using_font_oversampling>`
如果启用了字体过采样,则返回 ``true``\ 。见 :ref:`set_use_font_oversampling()<class_Window_method_set_use_font_oversampling>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_move_to_center:
.. rst-class:: classref-method
|void| **move_to_center**\ (\ ) :ref:`🔗<class_Window_method_move_to_center>`
Centers the window in the current screen. If the window is embedded, it is centered in the embedder :ref:`Viewport<class_Viewport>` instead.
.. rst-class:: classref-item-separator
----
.. _class_Window_method_move_to_foreground:
.. rst-class:: classref-method
|void| **move_to_foreground**\ (\ ) :ref:`🔗<class_Window_method_move_to_foreground>`
**已弃用:** Use :ref:`grab_focus()<class_Window_method_grab_focus>` instead.
使该窗口获得焦点,从而接收用户输入。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup:
.. rst-class:: classref-method
|void| **popup**\ (\ rect\: :ref:`Rect2i<class_Rect2i>` = Rect2i(0, 0, 0, 0)\ ) :ref:`🔗<class_Window_method_popup>`
显示该 **Window** 并将其设置为临时窗口(见 :ref:`transient<class_Window_property_transient>`\ )。如果提供了 ``rect``\ ,则会将其设为 **Window** 的大小。对主窗口调用时会失败。
如果 :ref:`ProjectSettings.display/window/subwindows/embed_subwindows<class_ProjectSettings_property_display/window/subwindows/embed_subwindows>```true``\ (单窗口模式),\ ``rect`` 使用全局坐标系,相对于主窗口的左上角(不含窗口的装饰)。如果 ``rect`` 的位置坐标为负数,则该窗口位于主窗口之外,因此可能不可见。
如果 :ref:`ProjectSettings.display/window/subwindows/embed_subwindows<class_ProjectSettings_property_display/window/subwindows/embed_subwindows>```false``\ (多窗口模式),\ ``rect`` 使用全局坐标系,相对于最左侧屏幕的左上角。如果 ``rect`` 的位置坐标为负数,则该窗口会被放置在该屏幕的左上角。
\ **注意:**\ 存在相关说明时,\ ``rect`` 必须使用全局坐标。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_centered:
.. rst-class:: classref-method
|void| **popup_centered**\ (\ minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0)\ ) :ref:`🔗<class_Window_method_popup_centered>`
在当前屏幕的中心弹出该 **Window**\ ,可以选择给定最小尺寸。如果该 **Window** 是嵌入的,它将在父 :ref:`Viewport<class_Viewport>` 中居中。
\ **注意:**\ 用 ``minsize`` 的默认值调用它等同于用 :ref:`size<class_Window_property_size>` 调用它。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_centered_clamped:
.. rst-class:: classref-method
|void| **popup_centered_clamped**\ (\ minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0), fallback_ratio\: :ref:`float<class_float>` = 0.75\ ) :ref:`🔗<class_Window_method_popup_centered_clamped>`
在父 **Window** 中居中弹出该 **Window**\ 。\ ``fallback_ratio`` 确定 **Window** 相对于其父级的最大尺寸。
\ **注意:**\ 用 ``minsize`` 的默认值调用它等同于用 :ref:`size<class_Window_property_size>` 调用它。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_centered_ratio:
.. rst-class:: classref-method
|void| **popup_centered_ratio**\ (\ ratio\: :ref:`float<class_float>` = 0.8\ ) :ref:`🔗<class_Window_method_popup_centered_ratio>`
如果 **Window** 为嵌入式窗口,则 **Window** 在弹出时会在嵌入器内居中,并按照嵌入器大小的比例 ``ratio`` 设置其大小。
如果 **Window** 为原生窗口,则 **Window** 在弹出时会在其父 **Window** 所在屏幕内居中,并按照屏幕大小的比例 ``ratio`` 设置其大小。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_exclusive:
.. rst-class:: classref-method
|void| **popup_exclusive**\ (\ from_node\: :ref:`Node<class_Node>`, rect\: :ref:`Rect2i<class_Rect2i>` = Rect2i(0, 0, 0, 0)\ ) :ref:`🔗<class_Window_method_popup_exclusive>`
尝试将该对话框的父节点设为最近的独占窗口,相对于 ``from_node``\ ,然后对其调用 :ref:`popup()<class_Window_method_popup>`\ 。对话框目前必须没有父节点,否则该方法会失败。
另见 :ref:`set_unparent_when_invisible()<class_Window_method_set_unparent_when_invisible>` 和 :ref:`Node.get_last_exclusive_window()<class_Node_method_get_last_exclusive_window>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_exclusive_centered:
.. rst-class:: classref-method
|void| **popup_exclusive_centered**\ (\ from_node\: :ref:`Node<class_Node>`, minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0)\ ) :ref:`🔗<class_Window_method_popup_exclusive_centered>`
尝试将该对话框的父节点设为最近的独占窗口,相对于 ``from_node``\ ,然后对其调用 :ref:`popup_centered()<class_Window_method_popup_centered>`\ 。对话框目前必须没有父节点,否则该方法会失败。
另见 :ref:`set_unparent_when_invisible()<class_Window_method_set_unparent_when_invisible>` 和 :ref:`Node.get_last_exclusive_window()<class_Node_method_get_last_exclusive_window>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_exclusive_centered_clamped:
.. rst-class:: classref-method
|void| **popup_exclusive_centered_clamped**\ (\ from_node\: :ref:`Node<class_Node>`, minsize\: :ref:`Vector2i<class_Vector2i>` = Vector2i(0, 0), fallback_ratio\: :ref:`float<class_float>` = 0.75\ ) :ref:`🔗<class_Window_method_popup_exclusive_centered_clamped>`
尝试将该对话框的父节点设为最近的独占窗口,相对于 ``from_node``\ ,然后对其调用 :ref:`popup_centered_clamped()<class_Window_method_popup_centered_clamped>`\ 。对话框目前必须没有父节点,否则该方法会失败。
另见 :ref:`set_unparent_when_invisible()<class_Window_method_set_unparent_when_invisible>` 和 :ref:`Node.get_last_exclusive_window()<class_Node_method_get_last_exclusive_window>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_exclusive_centered_ratio:
.. rst-class:: classref-method
|void| **popup_exclusive_centered_ratio**\ (\ from_node\: :ref:`Node<class_Node>`, ratio\: :ref:`float<class_float>` = 0.8\ ) :ref:`🔗<class_Window_method_popup_exclusive_centered_ratio>`
尝试将该对话框的父节点设为最近的独占窗口,相对于 ``from_node``\ ,然后对其调用 :ref:`popup_centered_ratio()<class_Window_method_popup_centered_ratio>`\ 。对话框目前必须没有父节点,否则该方法会失败。
另见 :ref:`set_unparent_when_invisible()<class_Window_method_set_unparent_when_invisible>` 和 :ref:`Node.get_last_exclusive_window()<class_Node_method_get_last_exclusive_window>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_exclusive_on_parent:
.. rst-class:: classref-method
|void| **popup_exclusive_on_parent**\ (\ from_node\: :ref:`Node<class_Node>`, parent_rect\: :ref:`Rect2i<class_Rect2i>`\ ) :ref:`🔗<class_Window_method_popup_exclusive_on_parent>`
尝试将该对话框的父节点设为最近的独占窗口,相对于 ``from_node``\ ,然后对其调用 :ref:`popup_on_parent()<class_Window_method_popup_on_parent>`\ 。对话框目前必须没有父节点,否则该方法会失败。
另见 :ref:`set_unparent_when_invisible()<class_Window_method_set_unparent_when_invisible>` 和 :ref:`Node.get_last_exclusive_window()<class_Node_method_get_last_exclusive_window>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_popup_on_parent:
.. rst-class:: classref-method
|void| **popup_on_parent**\ (\ parent_rect\: :ref:`Rect2i<class_Rect2i>`\ ) :ref:`🔗<class_Window_method_popup_on_parent>`
弹出该 **Window**\ ,位置会根据父级 **Window** 的位置进行偏移。如果该 **Window** 是内嵌的,则与 :ref:`popup()<class_Window_method_popup>` 等效。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_color_override:
.. rst-class:: classref-method
|void| **remove_theme_color_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_color_override>`
移除名为 ``name`` 的主题 :ref:`Color<class_Color>` 本地覆盖项,该覆盖项由 :ref:`add_theme_color_override()<class_Window_method_add_theme_color_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_constant_override:
.. rst-class:: classref-method
|void| **remove_theme_constant_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_constant_override>`
移除名为 ``name`` 的主题常量本地覆盖项,该覆盖项由 :ref:`add_theme_constant_override()<class_Window_method_add_theme_constant_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_font_override:
.. rst-class:: classref-method
|void| **remove_theme_font_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_font_override>`
移除名为 ``name`` 的主题 :ref:`Font<class_Font>` 本地覆盖项,该覆盖项由 :ref:`add_theme_font_override()<class_Window_method_add_theme_font_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_font_size_override:
.. rst-class:: classref-method
|void| **remove_theme_font_size_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_font_size_override>`
移除名为 ``name`` 的主题字体大小本地覆盖项,该覆盖项由 :ref:`add_theme_font_size_override()<class_Window_method_add_theme_font_size_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_icon_override:
.. rst-class:: classref-method
|void| **remove_theme_icon_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_icon_override>`
移除名为 ``name`` 的主题图标本地覆盖项,该覆盖项由 :ref:`add_theme_icon_override()<class_Window_method_add_theme_icon_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_remove_theme_stylebox_override:
.. rst-class:: classref-method
|void| **remove_theme_stylebox_override**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_Window_method_remove_theme_stylebox_override>`
移除名为 ``name`` 的主题 :ref:`StyleBox<class_StyleBox>` 本地覆盖项,该覆盖项由 :ref:`add_theme_stylebox_override()<class_Window_method_add_theme_stylebox_override>` 或检查器面板添加。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_request_attention:
.. rst-class:: classref-method
|void| **request_attention**\ (\ ) :ref:`🔗<class_Window_method_request_attention>`
告诉操作系统 **Window** 需要注意。这样会让该窗口以某种方式脱颖而出,具体形式取决于系统,例如可能会在任务栏上闪烁。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_reset_size:
.. rst-class:: classref-method
|void| **reset_size**\ (\ ) :ref:`🔗<class_Window_method_reset_size>`
将大小重置为最小大小,即 :ref:`min_size<class_Window_property_min_size>` 和(\ :ref:`wrap_controls<class_Window_property_wrap_controls>` 启用时)\ :ref:`get_contents_minimum_size()<class_Window_method_get_contents_minimum_size>` 之间的较大值。相当于调用 ``set_size(Vector2i())``\ (或低于最小值的任何大小)。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_flag:
.. rst-class:: classref-method
|void| **set_flag**\ (\ flag\: :ref:`Flags<enum_Window_Flags>`, enabled\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Window_method_set_flag>`
设置指定的窗口标志。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_ime_active:
.. rst-class:: classref-method
|void| **set_ime_active**\ (\ active\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Window_method_set_ime_active>`
如果 ``active````true``\ ,则启用系统的原生 IME输入法编辑器
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_ime_position:
.. rst-class:: classref-method
|void| **set_ime_position**\ (\ position\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`🔗<class_Window_method_set_ime_position>`
将 IME 移动到给定位置。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_layout_direction:
.. rst-class:: classref-method
|void| **set_layout_direction**\ (\ direction\: :ref:`LayoutDirection<enum_Window_LayoutDirection>`\ ) :ref:`🔗<class_Window_method_set_layout_direction>`
设置布局方向和文本书写方向。某些语言需要从右至左的布局(例如阿拉伯语和希伯来语)。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_unparent_when_invisible:
.. rst-class:: classref-method
|void| **set_unparent_when_invisible**\ (\ unparent\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Window_method_set_unparent_when_invisible>`
如果 ``unparent````true``\ ,则窗口会在隐藏时自动解除与父节点的关系。
\ **注意:**\ 请确保存在对该节点的引用,否则该节点会变为孤立节点。没有父节点时,你还需要手动调用 :ref:`Node.queue_free()<class_Node_method_queue_free>` 来释放该窗口。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_set_use_font_oversampling:
.. rst-class:: classref-method
|void| **set_use_font_oversampling**\ (\ enable\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_Window_method_set_use_font_oversampling>`
启用字体过采样。会使得字体在放大后更好看。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_show:
.. rst-class:: classref-method
|void| **show**\ (\ ) :ref:`🔗<class_Window_method_show>`
让该 **Window** 出现。这样会启用与 **Window** 的交互,除了可见性之外不会更改其他任何属性(与 :ref:`popup()<class_Window_method_popup>` 不同)。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_start_drag:
.. rst-class:: classref-method
|void| **start_drag**\ (\ ) :ref:`🔗<class_Window_method_start_drag>`
在窗口上启动交互式拖动操作,使用当前鼠标位置。处理鼠标按钮按下事件时调用该方法可以模拟在窗口标题栏上按下的事件。使用该方法可以使窗口参与空间切换、平铺等系统功能。
.. rst-class:: classref-item-separator
----
.. _class_Window_method_start_resize:
.. rst-class:: classref-method
|void| **start_resize**\ (\ edge\: :ref:`WindowResizeEdge<enum_DisplayServer_WindowResizeEdge>`\ ) :ref:`🔗<class_Window_method_start_resize>`
在窗口上启动交互式调整大小操作,使用当前鼠标位置。处理鼠标按钮按下事件时调用该方法可以模拟在窗口边缘上按下的事件。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
主题属性说明
------------
.. _class_Window_theme_color_title_color:
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` **title_color** = ``Color(0.875, 0.875, 0.875, 1)`` :ref:`🔗<class_Window_theme_color_title_color>`
标题文本的颜色。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_color_title_outline_modulate:
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` **title_outline_modulate** = ``Color(0, 0, 0, 1)`` :ref:`🔗<class_Window_theme_color_title_outline_modulate>`
标题文本轮廓的颜色。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_constant_close_h_offset:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **close_h_offset** = ``18`` :ref:`🔗<class_Window_theme_constant_close_h_offset>`
关闭按钮的水平位置偏移,相对于标题栏的末端,朝向标题栏的开头。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_constant_close_v_offset:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **close_v_offset** = ``24`` :ref:`🔗<class_Window_theme_constant_close_v_offset>`
关闭按钮的垂直位置偏移,相对于标题栏的底部,朝向标题栏的顶部。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_constant_resize_margin:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **resize_margin** = ``4`` :ref:`🔗<class_Window_theme_constant_resize_margin>`
定义了窗口边框外侧可以使用鼠标抓取和调整大小的边距。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_constant_title_height:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **title_height** = ``36`` :ref:`🔗<class_Window_theme_constant_title_height>`
标题栏的高度。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_constant_title_outline_size:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **title_outline_size** = ``0`` :ref:`🔗<class_Window_theme_constant_title_outline_size>`
标题轮廓的尺寸。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_font_title_font:
.. rst-class:: classref-themeproperty
:ref:`Font<class_Font>` **title_font** :ref:`🔗<class_Window_theme_font_title_font>`
用于绘制标题的字体。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_font_size_title_font_size:
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` **title_font_size** :ref:`🔗<class_Window_theme_font_size_title_font_size>`
标题字体的大小。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_icon_close:
.. rst-class:: classref-themeproperty
:ref:`Texture2D<class_Texture2D>` **close** :ref:`🔗<class_Window_theme_icon_close>`
关闭按钮的图标。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_icon_close_pressed:
.. rst-class:: classref-themeproperty
:ref:`Texture2D<class_Texture2D>` **close_pressed** :ref:`🔗<class_Window_theme_icon_close_pressed>`
关闭按钮被按下时的图标。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_style_embedded_border:
.. rst-class:: classref-themeproperty
:ref:`StyleBox<class_StyleBox>` **embedded_border** :ref:`🔗<class_Window_theme_style_embedded_border>`
**Window** 为嵌入模式时使用的背景样式。请注意,背景仅绘制在窗口内容的下方,不包括标题。要得到合适的边框和标题栏样式,可以使用 :ref:`StyleBoxFlat<class_StyleBoxFlat>```expand_margin_*`` 属性。
\ **注意:**\ 只有在启用 :ref:`transparent<class_Window_property_transparent>` 时,内容背景才会可见。
.. rst-class:: classref-item-separator
----
.. _class_Window_theme_style_embedded_unfocused_border:
.. rst-class:: classref-themeproperty
:ref:`StyleBox<class_StyleBox>` **embedded_unfocused_border** :ref:`🔗<class_Window_theme_style_embedded_unfocused_border>`
**Window** 为嵌入式且未获得焦点时使用的背景样式。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |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 (无返回值。)`