Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Window

Inherits: Viewport < Node < Object

Inherited By: AcceptDialog, Popup

Base class for all windows, dialogs, and popups.

描述

A node that creates a window. The window can either be a native system window or embedded inside another Window (see Viewport.gui_embed_subwindows).

At runtime, Windows will not close automatically when requested. You need to handle it manually using the close_requested signal (this applies both to pressing the close button and clicking outside of a popup).

属性

bool

always_on_top

false

bool

auto_translate

true

bool

borderless

false

ContentScaleAspect

content_scale_aspect

0

float

content_scale_factor

1.0

ContentScaleMode

content_scale_mode

0

Vector2i

content_scale_size

Vector2i(0, 0)

ContentScaleStretch

content_scale_stretch

0

int

current_screen

bool

exclusive

false

bool

extend_to_title

false

WindowInitialPosition

initial_position

0

Vector2i

max_size

Vector2i(0, 0)

Vector2i

min_size

Vector2i(0, 0)

Mode

mode

0

bool

mouse_passthrough

false

PackedVector2Array

mouse_passthrough_polygon

PackedVector2Array()

bool

popup_window

false

Vector2i

position

Vector2i(0, 0)

Vector2i

size

Vector2i(100, 100)

Theme

theme

StringName

theme_type_variation

&""

String

title

""

bool

transient

false

bool

transparent

false

bool

unfocusable

false

bool

unresizable

false

bool

visible

true

bool

wrap_controls

false

Methods

Vector2

_get_contents_minimum_size ( ) virtual const

void

add_theme_color_override ( StringName name, Color color )

void

add_theme_constant_override ( StringName name, int constant )

void

add_theme_font_override ( StringName name, Font font )

void

add_theme_font_size_override ( StringName name, int font_size )

void

add_theme_icon_override ( StringName name, Texture2D texture )

void

add_theme_stylebox_override ( StringName name, StyleBox stylebox )

void

begin_bulk_theme_override ( )

bool

can_draw ( ) const

void

child_controls_changed ( )

void

end_bulk_theme_override ( )

Vector2

get_contents_minimum_size ( ) const

bool

get_flag ( Flags flag ) const

LayoutDirection

get_layout_direction ( ) const

Vector2i

get_position_with_decorations ( ) const

Vector2i

get_size_with_decorations ( ) const

Color

get_theme_color ( StringName name, StringName theme_type="" ) const

int

get_theme_constant ( StringName name, StringName theme_type="" ) const

float

get_theme_default_base_scale ( ) const

Font

get_theme_default_font ( ) const

int

get_theme_default_font_size ( ) const

Font

get_theme_font ( StringName name, StringName theme_type="" ) const

int

get_theme_font_size ( StringName name, StringName theme_type="" ) const

Texture2D

get_theme_icon ( StringName name, StringName theme_type="" ) const

StyleBox

get_theme_stylebox ( StringName name, StringName theme_type="" ) const

int

get_window_id ( ) const

void

grab_focus ( )

bool

has_focus ( ) const

bool

has_theme_color ( StringName name, StringName theme_type="" ) const

bool

has_theme_color_override ( StringName name ) const

bool

has_theme_constant ( StringName name, StringName theme_type="" ) const

bool

has_theme_constant_override ( StringName name ) const

bool

has_theme_font ( StringName name, StringName theme_type="" ) const

bool

has_theme_font_override ( StringName name ) const

bool

has_theme_font_size ( StringName name, StringName theme_type="" ) const

bool

has_theme_font_size_override ( StringName name ) const

bool

has_theme_icon ( StringName name, StringName theme_type="" ) const

bool

has_theme_icon_override ( StringName name ) const

bool

has_theme_stylebox ( StringName name, StringName theme_type="" ) const

bool

has_theme_stylebox_override ( StringName name ) const

void

hide ( )

bool

is_embedded ( ) const

bool

is_layout_rtl ( ) const

bool

is_maximize_allowed ( ) const

bool

is_using_font_oversampling ( ) const

void

move_to_center ( )

void

move_to_foreground ( )

void

popup ( Rect2i rect=Rect2i(0, 0, 0, 0) )

void

popup_centered ( Vector2i minsize=Vector2i(0, 0) )

void

popup_centered_clamped ( Vector2i minsize=Vector2i(0, 0), float fallback_ratio=0.75 )

void

popup_centered_ratio ( float ratio=0.8 )

void

popup_exclusive ( Node from_node, Rect2i rect=Rect2i(0, 0, 0, 0) )

void

popup_exclusive_centered ( Node from_node, Vector2i minsize=Vector2i(0, 0) )

void

popup_exclusive_centered_clamped ( Node from_node, Vector2i minsize=Vector2i(0, 0), float fallback_ratio=0.75 )

void

popup_exclusive_centered_ratio ( Node from_node, float ratio=0.8 )

void

popup_exclusive_on_parent ( Node from_node, Rect2i parent_rect )

void

popup_on_parent ( Rect2i parent_rect )

void

remove_theme_color_override ( StringName name )

void

remove_theme_constant_override ( StringName name )

void

remove_theme_font_override ( StringName name )

void

remove_theme_font_size_override ( StringName name )

void

remove_theme_icon_override ( StringName name )

void

remove_theme_stylebox_override ( StringName name )

void

request_attention ( )

void

reset_size ( )

void

set_flag ( Flags flag, bool enabled )

void

set_ime_active ( bool active )

void

set_ime_position ( Vector2i position )

void

set_layout_direction ( LayoutDirection direction )

void

set_unparent_when_invisible ( bool unparent )

void

set_use_font_oversampling ( bool enable )

void

show ( )

Theme Properties

Color

title_color

Color(0.875, 0.875, 0.875, 1)

Color

title_outline_modulate

Color(1, 1, 1, 1)

int

close_h_offset

18

int

close_v_offset

24

int

resize_margin

4

int

title_height

36

int

title_outline_size

0

Font

title_font

int

title_font_size

Texture2D

close

Texture2D

close_pressed

StyleBox

embedded_border

StyleBox

embedded_unfocused_border


信号

about_to_popup ( )

Emitted right after popup call, before the Window appears or does anything.


close_requested ( )

Emitted when the Window's close button is pressed or when popup_window is enabled and user clicks outside the window.

This signal can be used to handle window closing, e.g. by connecting it to hide.


dpi_changed ( )

Emitted when the Window's DPI changes as a result of OS-level changes (e.g. moving the window from a Retina display to a lower resolution one).

Note: Only implemented on macOS.


files_dropped ( PackedStringArray files )

Emitted when files are dragged from the OS file manager and dropped in the game window. The argument is a list of file paths.

Note that this method only works with native windows, i.e. the main window and Window-derived nodes when Viewport.gui_embed_subwindows is disabled in the main viewport.

Example usage:

func _ready():
    get_viewport().files_dropped.connect(on_files_dropped)

func on_files_dropped(files):
    print(files)

focus_entered ( )

Emitted when the Window gains focus.


focus_exited ( )

Emitted when the Window loses its focus.


go_back_requested ( )

Emitted when a go back request is sent (e.g. pressing the "Back" button on Android), right after Node.NOTIFICATION_WM_GO_BACK_REQUEST.


mouse_entered ( )

Emitted when the mouse cursor enters the Window's visible area, that is not occluded behind other Controls or windows, provided its Viewport.gui_disable_input is false and regardless if it's currently focused or not.


mouse_exited ( )

Emitted when the mouse cursor leaves the Window's visible area, that is not occluded behind other Controls or windows, provided its Viewport.gui_disable_input is false and regardless if it's currently focused or not.


theme_changed ( )

Emitted when the NOTIFICATION_THEME_CHANGED notification is sent.


titlebar_changed ( )

Emitted when window title bar decorations are changed, e.g. macOS window enter/exit full screen mode, or extend-to-title flag is changed.


visibility_changed ( )

Emitted when Window is made visible or disappears.


window_input ( InputEvent event )

Emitted when the Window is currently focused and receives any input, passing the received event as an argument. The event's position, if present, is in the embedder's coordinate system.


Enumerations

enum Mode:

Mode MODE_WINDOWED = 0

Windowed mode, i.e. Window doesn't occupy the whole screen (unless set to the size of the screen).

Mode MODE_MINIMIZED = 1

Minimized window mode, i.e. Window is not visible and available on window manager's window list. Normally happens when the minimize button is pressed.

Mode MODE_MAXIMIZED = 2

Maximized window mode, i.e. Window will occupy whole screen area except task bar and still display its borders. Normally happens when the maximize button is pressed.

Mode MODE_FULLSCREEN = 3

Full screen window mode. Note that this is not exclusive full screen. On Windows and Linux, a borderless window is used to emulate full screen. On macOS, a new desktop is used to display the running project.

Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling full screen mode.

Mode MODE_EXCLUSIVE_FULLSCREEN = 4

Exclusive full screen window mode. This mode is implemented on Windows only. On other platforms, it is equivalent to MODE_FULLSCREEN.

Only one window in exclusive full screen mode can be visible on a given screen at a time. If multiple windows are in exclusive full screen mode for the same screen, the last one being set to this mode takes precedence.

Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling full screen mode.


enum Flags:

Flags FLAG_RESIZE_DISABLED = 0

The window can't be resized by dragging its resize grip. It's still possible to resize the window using size. This flag is ignored for full screen windows. Set with unresizable.

Flags FLAG_BORDERLESS = 1

The window do not have native title bar and other decorations. This flag is ignored for full-screen windows. Set with borderless.

Flags FLAG_ALWAYS_ON_TOP = 2

The window is floating on top of all other windows. This flag is ignored for full-screen windows. Set with always_on_top.

Flags FLAG_TRANSPARENT = 3

The window background can be transparent. Set with transparent.

Note: This flag has no effect if either ProjectSettings.display/window/per_pixel_transparency/allowed, or the window's Viewport.transparent_bg is set to false.

Flags FLAG_NO_FOCUS = 4

The window can't be focused. No-focus window will ignore all input, except mouse clicks. Set with unfocusable.

Flags FLAG_POPUP = 5

Window is part of menu or OptionButton dropdown. This flag can't be changed when the window is visible. An active popup window will exclusively receive all input, without stealing focus from its parent. Popup windows are automatically closed when uses click outside it, or when an application is switched. Popup window must have transient parent set (see transient).

Note: This flag has no effect in embedded windows (unless said window is a Popup).

Flags FLAG_EXTEND_TO_TITLE = 6

Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons. Set with extend_to_title.

Note: This flag is implemented only on macOS.

Note: This flag has no effect in embedded windows.

Flags FLAG_MOUSE_PASSTHROUGH = 7

All mouse events are passed to the underlying window of the same application.

Note: This flag has no effect in embedded windows.

Flags FLAG_MAX = 8

Max value of the Flags.


enum ContentScaleMode:

ContentScaleMode CONTENT_SCALE_MODE_DISABLED = 0

The content will not be scaled to match the Window's size.

ContentScaleMode CONTENT_SCALE_MODE_CANVAS_ITEMS = 1

The content will be rendered at the target size. This is more performance-expensive than CONTENT_SCALE_MODE_VIEWPORT, but provides better results.

ContentScaleMode CONTENT_SCALE_MODE_VIEWPORT = 2

The content will be rendered at the base size and then scaled to the target size. More performant than CONTENT_SCALE_MODE_CANVAS_ITEMS, but results in pixelated image.


enum ContentScaleAspect:

ContentScaleAspect CONTENT_SCALE_ASPECT_IGNORE = 0

The aspect will be ignored. Scaling will simply stretch the content to fit the target size.

ContentScaleAspect CONTENT_SCALE_ASPECT_KEEP = 1

The content's aspect will be preserved. If the target size has different aspect from the base one, the image will be centered and black bars will appear on left and right sides.

ContentScaleAspect CONTENT_SCALE_ASPECT_KEEP_WIDTH = 2

The content can be expanded vertically. Scaling horizontally will result in keeping the width ratio and then black bars on left and right sides.

ContentScaleAspect CONTENT_SCALE_ASPECT_KEEP_HEIGHT = 3

The content can be expanded horizontally. Scaling vertically will result in keeping the height ratio and then black bars on top and bottom sides.

ContentScaleAspect CONTENT_SCALE_ASPECT_EXPAND = 4

The content's aspect will be preserved. If the target size has different aspect from the base one, the content will stay in the top-left corner and add an extra visible area in the stretched space.


enum ContentScaleStretch:

ContentScaleStretch CONTENT_SCALE_STRETCH_FRACTIONAL = 0

The content will be stretched according to a fractional factor. This fills all the space available in the window, but allows "pixel wobble" to occur due to uneven pixel scaling.

ContentScaleStretch CONTENT_SCALE_STRETCH_INTEGER = 1

The content will be stretched only according to an integer factor, preserving sharp pixels. This may leave a black background visible on the window's edges depending on the window size.


enum LayoutDirection:

LayoutDirection LAYOUT_DIRECTION_INHERITED = 0

Automatic layout direction, determined from the parent window layout direction.

LayoutDirection LAYOUT_DIRECTION_LOCALE = 1

Automatic layout direction, determined from the current locale.

LayoutDirection LAYOUT_DIRECTION_LTR = 2

Left-to-right layout direction.

LayoutDirection LAYOUT_DIRECTION_RTL = 3

Right-to-left layout direction.


enum WindowInitialPosition:

WindowInitialPosition WINDOW_INITIAL_POSITION_ABSOLUTE = 0

Initial window position is determined by position.

WindowInitialPosition WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN = 1

Initial window position is the center of the primary screen.

WindowInitialPosition WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN = 2

Initial window position is the center of the main window screen.

WindowInitialPosition WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN = 3

Initial window position is the center of current_screen screen.

WindowInitialPosition WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS = 4

Initial window position is the center of the screen containing the mouse pointer.

WindowInitialPosition WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS = 5

Initial window position is the center of the screen containing the window with the keyboard focus.


常量

NOTIFICATION_VISIBILITY_CHANGED = 30

Emitted when Window's visibility changes, right before visibility_changed.

NOTIFICATION_THEME_CHANGED = 32

Sent when the node needs to refresh its theme items. This happens in one of the following cases:

  • The theme property is changed on this node or any of its ancestors.

  • The theme_type_variation property is changed on this node.

  • The node enters the scene tree.

Note: As an optimization, this notification won't be sent from changes that occur while this node is outside of the scene tree. Instead, all of the theme item updates can be applied at once when the node enters the scene tree.


Property Descriptions

bool always_on_top = false

If true, the window will be on top of all other windows. Does not work if transient is enabled.


bool auto_translate = true

  • void set_auto_translate ( bool value )

  • bool is_auto_translating ( )

Toggles if any text should automatically change to its translated version depending on the current locale.


bool borderless = false

If true, the window will have no borders.


ContentScaleAspect content_scale_aspect = 0

Specifies how the content's aspect behaves when the Window is resized. The base aspect is determined by content_scale_size.


float content_scale_factor = 1.0

  • void set_content_scale_factor ( float value )

  • float get_content_scale_factor ( )

Specifies the base scale of Window's content when its size is equal to content_scale_size.


ContentScaleMode content_scale_mode = 0

Specifies how the content is scaled when the Window is resized.


Vector2i content_scale_size = Vector2i(0, 0)

  • void set_content_scale_size ( Vector2i value )

  • Vector2i get_content_scale_size ( )

Base size of the content (i.e. nodes that are drawn inside the window). If non-zero, Window's content will be scaled when the window is resized to a different size.


ContentScaleStretch content_scale_stretch = 0

The policy to use to determine the final scale factor for 2D elements. This affects how content_scale_factor is applied, in addition to the automatic scale factor determined by content_scale_size.


int current_screen

  • void set_current_screen ( int value )

  • int get_current_screen ( )

The screen the window is currently on.


bool exclusive = false

  • void set_exclusive ( bool value )

  • bool is_exclusive ( )

If true, the Window will be in exclusive mode. Exclusive windows are always on top of their parent and will block all input going to the parent Window.

Needs transient enabled to work.


bool extend_to_title = false

If true, the Window contents is expanded to the full size of the window, window title bar is transparent.

Note: This property is implemented only on macOS.

Note: This property only works with native windows.


WindowInitialPosition initial_position = 0

Specifies the initial type of position for the Window. See WindowInitialPosition constants.


Vector2i max_size = Vector2i(0, 0)

If non-zero, the Window can't be resized to be bigger than this size.

Note: This property will be ignored if the value is lower than min_size.


Vector2i min_size = Vector2i(0, 0)

If non-zero, the Window can't be resized to be smaller than this size.

Note: This property will be ignored in favor of get_contents_minimum_size if wrap_controls is enabled and if its size is bigger.


Mode mode = 0

  • void set_mode ( Mode value )

  • Mode get_mode ( )

Set's the window's current mode.

Note: Fullscreen mode is not exclusive full screen on Windows and Linux.

Note: This method only works with native windows, i.e. the main window and Window-derived nodes when Viewport.gui_embed_subwindows is disabled in the main viewport.


bool mouse_passthrough = false

If true, all mouse events will be passed to the underlying window of the same application. See also mouse_passthrough_polygon.

Note: This property is implemented on Linux (X11), macOS and Windows.

Note: This property only works with native windows.


PackedVector2Array mouse_passthrough_polygon = PackedVector2Array()

Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through.

Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior).

# Set region, using Path2D node.
$Window.mouse_passthrough_polygon = $Path2D.curve.get_baked_points()

# Set region, using Polygon2D node.
$Window.mouse_passthrough_polygon = $Polygon2D.polygon

# Reset region to default.
$Window.mouse_passthrough_polygon = []

Note: This property is ignored if mouse_passthrough is set to true.

Note: On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is.

Note: This property is implemented on Linux (X11), macOS and Windows.


bool popup_window = false

If true, the Window will be considered a popup. Popups are sub-windows that don't show as separate windows in system's window manager's window list and will send close request when anything is clicked outside of them (unless exclusive is enabled).


Vector2i position = Vector2i(0, 0)

The window's position in pixels.

If ProjectSettings.display/window/subwindows/embed_subwindows is false, the position is in absolute screen coordinates. This typically applies to editor plugins. If the setting is true, the window's position is in the coordinates of its parent Viewport.

Note: This property only works if initial_position is set to WINDOW_INITIAL_POSITION_ABSOLUTE.


Vector2i size = Vector2i(100, 100)

The window's size in pixels.


Theme theme

  • void set_theme ( Theme value )

  • Theme get_theme ( )

The Theme resource this node and all its Control and Window children use. If a child node has its own Theme resource set, theme items are merged with child's definitions having higher priority.

Note: Window styles will have no effect unless the window is embedded.


StringName theme_type_variation = &""

The name of a theme type variation used by this Window to look up its own theme items. See Control.theme_type_variation for more details.


String title = ""

The window's title. If the Window is native, title styles set in Theme will have no effect.


bool transient = false

  • void set_transient ( bool value )

  • bool is_transient ( )

If true, the Window is transient, i.e. it's considered a child of another Window. The transient window will be destroyed with its transient parent and will return focus to their parent when closed. The transient window is displayed on top of a non-exclusive full-screen parent window. Transient windows can't enter full-screen mode.

Note that behavior might be different depending on the platform.


bool transparent = false

If true, the Window's background can be transparent. This is best used with embedded windows.

Note: Transparency support is implemented on Linux, macOS and Windows, but availability might vary depending on GPU driver, display manager, and compositor capabilities.

Note: This property has no effect if either ProjectSettings.display/window/per_pixel_transparency/allowed, or the window's Viewport.transparent_bg is set to false.


bool unfocusable = false

If true, the Window can't be focused nor interacted with. It can still be visible.


bool unresizable = false

If true, the window can't be resized. Minimize and maximize buttons are disabled.


bool visible = true

  • void set_visible ( bool value )

  • bool is_visible ( )

If true, the window is visible.


bool wrap_controls = false

  • void set_wrap_controls ( bool value )

  • bool is_wrapping_controls ( )

If true, the window's size will automatically update when a child node is added or removed, ignoring min_size if the new size is bigger.

If false, you need to call child_controls_changed manually.


Method Descriptions

Vector2 _get_contents_minimum_size ( ) virtual const

Virtual method to be implemented by the user. Overrides the value returned by get_contents_minimum_size.


void add_theme_color_override ( StringName name, Color color )

Creates a local override for a theme Color with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_color_override.

See also get_theme_color and Control.add_theme_color_override for more details.


void add_theme_constant_override ( StringName name, int constant )

Creates a local override for a theme constant with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_constant_override.

See also get_theme_constant.


void add_theme_font_override ( StringName name, Font font )

Creates a local override for a theme Font with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_font_override.

See also get_theme_font.


void add_theme_font_size_override ( StringName name, int font_size )

Creates a local override for a theme font size with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_font_size_override.

See also get_theme_font_size.


void add_theme_icon_override ( StringName name, Texture2D texture )

Creates a local override for a theme icon with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_icon_override.

See also get_theme_icon.


void add_theme_stylebox_override ( StringName name, StyleBox stylebox )

Creates a local override for a theme StyleBox with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with remove_theme_stylebox_override.

See also get_theme_stylebox and Control.add_theme_stylebox_override for more details.


void begin_bulk_theme_override ( )

Prevents *_theme_*_override methods from emitting NOTIFICATION_THEME_CHANGED until end_bulk_theme_override is called.


bool can_draw ( ) const

Returns whether the window is being drawn to the screen.


void child_controls_changed ( )

Requests an update of the Window size to fit underlying Control nodes.


void end_bulk_theme_override ( )

Ends a bulk theme override update. See begin_bulk_theme_override.


Vector2 get_contents_minimum_size ( ) const

Returns the combined minimum size from the child Control nodes of the window. Use child_controls_changed to update it when children nodes have changed.

The value returned by this method can be overridden with _get_contents_minimum_size.


bool get_flag ( Flags flag ) const

Returns true if the flag is set.


LayoutDirection get_layout_direction ( ) const

Returns layout direction and text writing direction.


Vector2i get_position_with_decorations ( ) const

Returns the window's position including its border.


Vector2i get_size_with_decorations ( ) const

Returns the window's size including its border.


Color get_theme_color ( StringName name, StringName theme_type="" ) const

Returns a Color from the first matching Theme in the tree if that Theme has a color item with the specified name and theme_type.

See Control.get_theme_color for more details.


int get_theme_constant ( StringName name, StringName theme_type="" ) const

Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified name and theme_type.

See Control.get_theme_color for more details.


float get_theme_default_base_scale ( ) const

Returns the default base scale value from the first matching Theme in the tree if that Theme has a valid Theme.default_base_scale value.

See Control.get_theme_color for details.


Font get_theme_default_font ( ) const

Returns the default font from the first matching Theme in the tree if that Theme has a valid Theme.default_font value.

See Control.get_theme_color for details.


int get_theme_default_font_size ( ) const

Returns the default font size value from the first matching Theme in the tree if that Theme has a valid Theme.default_font_size value.

See Control.get_theme_color for details.


Font get_theme_font ( StringName name, StringName theme_type="" ) const

Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified name and theme_type.

See Control.get_theme_color for details.


int get_theme_font_size ( StringName name, StringName theme_type="" ) const

Returns a font size from the first matching Theme in the tree if that Theme has a font size item with the specified name and theme_type.

See Control.get_theme_color for details.


Texture2D get_theme_icon ( StringName name, StringName theme_type="" ) const

Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified name and theme_type.

See Control.get_theme_color for details.


StyleBox get_theme_stylebox ( StringName name, StringName theme_type="" ) const

Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified name and theme_type.

See Control.get_theme_color for details.


int get_window_id ( ) const

Returns the ID of the window.


void grab_focus ( )

Causes the window to grab focus, allowing it to receive user input.


bool has_focus ( ) const

Returns true if the window is focused.


bool has_theme_color ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has a color item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_color_override ( StringName name ) const

Returns true if there is a local override for a theme Color with the specified name in this Control node.

See add_theme_color_override.


bool has_theme_constant ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has a constant item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_constant_override ( StringName name ) const

Returns true if there is a local override for a theme constant with the specified name in this Control node.

See add_theme_constant_override.


bool has_theme_font ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has a font item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_font_override ( StringName name ) const

Returns true if there is a local override for a theme Font with the specified name in this Control node.

See add_theme_font_override.


bool has_theme_font_size ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has a font size item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_font_size_override ( StringName name ) const

Returns true if there is a local override for a theme font size with the specified name in this Control node.

See add_theme_font_size_override.


bool has_theme_icon ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has an icon item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_icon_override ( StringName name ) const

Returns true if there is a local override for a theme icon with the specified name in this Control node.

See add_theme_icon_override.


bool has_theme_stylebox ( StringName name, StringName theme_type="" ) const

Returns true if there is a matching Theme in the tree that has a stylebox item with the specified name and theme_type.

See Control.get_theme_color for details.


bool has_theme_stylebox_override ( StringName name ) const

Returns true if there is a local override for a theme StyleBox with the specified name in this Control node.

See add_theme_stylebox_override.


void hide ( )

Hides the window. This is not the same as minimized state. Hidden window can't be interacted with and needs to be made visible with show.


bool is_embedded ( ) const

Returns true if the window is currently embedded in another window.


bool is_layout_rtl ( ) const

Returns true if layout is right-to-left.


bool is_maximize_allowed ( ) const

Returns true if the window can be maximized (the maximize button is enabled).


bool is_using_font_oversampling ( ) const

Returns true if font oversampling is enabled. See set_use_font_oversampling.


void move_to_center ( )

Centers a native window on the current screen and an embedded window on its embedder Viewport.


void move_to_foreground ( )

Moves the Window on top of other windows and focuses it.


void popup ( Rect2i rect=Rect2i(0, 0, 0, 0) )

Shows the Window and makes it transient (see transient). If rect is provided, it will be set as the Window's size. Fails if called on the main window.


void popup_centered ( Vector2i minsize=Vector2i(0, 0) )

Popups the Window at the center of the current screen, with optionally given minimum size. If the Window is embedded, it will be centered in the parent Viewport instead.

Note: Calling it with the default value of minsize is equivalent to calling it with size.


void popup_centered_clamped ( Vector2i minsize=Vector2i(0, 0), float fallback_ratio=0.75 )

Popups the Window centered inside its parent Window. fallback_ratio determines the maximum size of the Window, in relation to its parent.

Note: Calling it with the default value of minsize is equivalent to calling it with size.


void popup_centered_ratio ( float ratio=0.8 )

If Window is embedded, popups the Window centered inside its embedder and sets its size as a ratio of embedder's size.

If Window is a native window, popups the Window centered inside the screen of its parent Window and sets its size as a ratio of the screen size.


void popup_exclusive ( Node from_node, Rect2i rect=Rect2i(0, 0, 0, 0) )

Attempts to parent this dialog to the last exclusive window relative to from_node, and then calls popup on it. The dialog must have no current parent, otherwise the method fails.

See also set_unparent_when_invisible and Node.get_last_exclusive_window.


void popup_exclusive_centered ( Node from_node, Vector2i minsize=Vector2i(0, 0) )

Attempts to parent this dialog to the last exclusive window relative to from_node, and then calls popup_centered on it. The dialog must have no current parent, otherwise the method fails.

See also set_unparent_when_invisible and Node.get_last_exclusive_window.


void popup_exclusive_centered_clamped ( Node from_node, Vector2i minsize=Vector2i(0, 0), float fallback_ratio=0.75 )

Attempts to parent this dialog to the last exclusive window relative to from_node, and then calls popup_centered_clamped on it. The dialog must have no current parent, otherwise the method fails.

See also set_unparent_when_invisible and Node.get_last_exclusive_window.


void popup_exclusive_centered_ratio ( Node from_node, float ratio=0.8 )

Attempts to parent this dialog to the last exclusive window relative to from_node, and then calls popup_centered_ratio on it. The dialog must have no current parent, otherwise the method fails.

See also set_unparent_when_invisible and Node.get_last_exclusive_window.


void popup_exclusive_on_parent ( Node from_node, Rect2i parent_rect )

Attempts to parent this dialog to the last exclusive window relative to from_node, and then calls popup_on_parent on it. The dialog must have no current parent, otherwise the method fails.

See also set_unparent_when_invisible and Node.get_last_exclusive_window.


void popup_on_parent ( Rect2i parent_rect )

Popups the Window with a position shifted by parent Window's position. If the Window is embedded, has the same effect as popup.


void remove_theme_color_override ( StringName name )

Removes a local override for a theme Color with the specified name previously added by add_theme_color_override or via the Inspector dock.


void remove_theme_constant_override ( StringName name )

Removes a local override for a theme constant with the specified name previously added by add_theme_constant_override or via the Inspector dock.


void remove_theme_font_override ( StringName name )

Removes a local override for a theme Font with the specified name previously added by add_theme_font_override or via the Inspector dock.


void remove_theme_font_size_override ( StringName name )

Removes a local override for a theme font size with the specified name previously added by add_theme_font_size_override or via the Inspector dock.


void remove_theme_icon_override ( StringName name )

Removes a local override for a theme icon with the specified name previously added by add_theme_icon_override or via the Inspector dock.


void remove_theme_stylebox_override ( StringName name )

Removes a local override for a theme StyleBox with the specified name previously added by add_theme_stylebox_override or via the Inspector dock.


void request_attention ( )

Tells the OS that the Window needs an attention. This makes the window stand out in some way depending on the system, e.g. it might blink on the task bar.


void reset_size ( )

Resets the size to the minimum size, which is the max of min_size and (if wrap_controls is enabled) get_contents_minimum_size. This is equivalent to calling set_size(Vector2i()) (or any size below the minimum).


void set_flag ( Flags flag, bool enabled )

Sets a specified window flag.


void set_ime_active ( bool active )

If active is true, enables system's native IME (Input Method Editor).


void set_ime_position ( Vector2i position )

Moves IME to the given position.


void set_layout_direction ( LayoutDirection direction )

Sets layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew).


void set_unparent_when_invisible ( bool unparent )

If unparent is true, the window is automatically unparented when going invisible.

Note: Make sure to keep a reference to the node, otherwise it will be orphaned. You also need to manually call Node.queue_free to free the window if it's not parented.


void set_use_font_oversampling ( bool enable )

Enables font oversampling. This makes fonts look better when they are scaled up.


void show ( )

Makes the Window appear. This enables interactions with the Window and doesn't change any of its property other than visibility (unlike e.g. popup).


Theme Property Descriptions

Color title_color = Color(0.875, 0.875, 0.875, 1)

The color of the title's text.


Color title_outline_modulate = Color(1, 1, 1, 1)

The color of the title's text outline.


int close_h_offset = 18

Horizontal position offset of the close button.


int close_v_offset = 24

Vertical position offset of the close button.


int resize_margin = 4

Defines the outside margin at which the window border can be grabbed with mouse and resized.


int title_height = 36

Height of the title bar.


int title_outline_size = 0

The size of the title outline.


Font title_font

The font used to draw the title.


int title_font_size

The size of the title font.


Texture2D close

The icon for the close button.


Texture2D close_pressed

The icon for the close button when it's being pressed.


StyleBox embedded_border

The background style used when the Window is embedded. Note that this is drawn only under the window's content, excluding the title. For proper borders and title bar style, you can use expand_margin_* properties of StyleBoxFlat.

Note: The content background will not be visible unless transparent is enabled.


StyleBox embedded_unfocused_border

The background style used when the Window is embedded and unfocused.