Window

Inherits: Viewport < Node < Object

Inherited By: AcceptDialog, Popup

Base class for all windows.

Description

A node that creates a window.

Methods

bool

can_draw ( ) const

void

child_controls_changed ( )

Vector2

get_contents_minimum_size ( ) const

bool

get_flag ( Flags flag ) const

LayoutDirection

get_layout_direction ( ) const

Vector2i

get_real_size ( ) 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

void

grab_focus ( )

bool

has_focus ( ) const

bool

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

bool

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

bool

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

bool

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

bool

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

bool

has_theme_stylebox ( StringName name, StringName theme_type="" ) 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_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_on_parent ( Rect2i parent_rect )

void

request_attention ( )

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_use_font_oversampling ( bool enable )

void

show ( )

Signals

  • about_to_popup ( )


  • close_requested ( )



  • focus_entered ( )


  • focus_exited ( )


  • go_back_requested ( )


  • mouse_entered ( )


  • mouse_exited ( )


  • visibility_changed ( )


Enumerations

enum Mode:

  • MODE_WINDOWED = 0 --- Windowed mode.

  • MODE_MINIMIZED = 1 --- Minimized window mode.

  • MODE_MAXIMIZED = 2 --- Maximized window mode.

  • MODE_FULLSCREEN = 3 --- Fullscreen window mode. Note that this is not exclusive fullscreen. On Windows and Linux, a borderless window is used to emulate fullscreen. On macOS, a new desktop is used to display the running project.

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


enum Flags:

  • FLAG_RESIZE_DISABLED = 0 --- The window's ability to be resized.

  • FLAG_BORDERLESS = 1 --- Borderless window.

  • FLAG_ALWAYS_ON_TOP = 2 --- Flag for making the window always on top of all other windows.

  • FLAG_TRANSPARENT = 3

  • FLAG_NO_FOCUS = 4

  • FLAG_MAX = 5


enum ContentScaleMode:

  • CONTENT_SCALE_MODE_DISABLED = 0

  • CONTENT_SCALE_MODE_CANVAS_ITEMS = 1

  • CONTENT_SCALE_MODE_VIEWPORT = 2


enum ContentScaleAspect:

  • CONTENT_SCALE_ASPECT_IGNORE = 0

  • CONTENT_SCALE_ASPECT_KEEP = 1

  • CONTENT_SCALE_ASPECT_KEEP_WIDTH = 2

  • CONTENT_SCALE_ASPECT_KEEP_HEIGHT = 3

  • CONTENT_SCALE_ASPECT_EXPAND = 4


enum LayoutDirection:

  • LAYOUT_DIRECTION_INHERITED = 0 --- Automatic layout direction, determined from the parent control layout direction.

  • LAYOUT_DIRECTION_LOCALE = 1 --- Automatic layout direction, determined from the current locale.

  • LAYOUT_DIRECTION_LTR = 2 --- Left-to-right layout direction.

  • LAYOUT_DIRECTION_RTL = 3 --- Right-to-left layout direction.

Constants

  • NOTIFICATION_VISIBILITY_CHANGED = 30

Property Descriptions

  • bool always_on_top

Default

false

Setter

set_flag(value)

Getter

get_flag()

If true, the window will be on top of all other windows.


  • bool auto_translate

Default

true

Setter

set_auto_translate(value)

Getter

is_auto_translating()

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


Default

false

Setter

set_flag(value)

Getter

get_flag()

If true, the window will have no borders.


Default

0

Setter

set_content_scale_aspect(value)

Getter

get_content_scale_aspect()


Default

0

Setter

set_content_scale_mode(value)

Getter

get_content_scale_mode()


Default

Vector2i(0, 0)

Setter

set_content_scale_size(value)

Getter

get_content_scale_size()


  • int current_screen

Default

0

Setter

set_current_screen(value)

Getter

get_current_screen()

The screen the window is currently on.


Default

false

Setter

set_exclusive(value)

Getter

is_exclusive()


Default

Vector2i(0, 0)

Setter

set_max_size(value)

Getter

get_max_size()


Default

Vector2i(0, 0)

Setter

set_min_size(value)

Getter

get_min_size()


Default

0

Setter

set_mode(value)

Getter

get_mode()

Set's the window's current mode.

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


Default

Vector2i(0, 0)

Setter

set_position(value)

Getter

get_position()

The window's position in pixels.


Default

Vector2i(100, 100)

Setter

set_size(value)

Getter

get_size()

The window's size in pixels.


Setter

set_theme(value)

Getter

get_theme()


Default

&""

Setter

set_theme_type_variation(value)

Getter

get_theme_type_variation()


Default

""

Setter

set_title(value)

Getter

get_title()

The window's title.


Default

false

Setter

set_transient(value)

Getter

is_transient()


Default

false

Setter

set_flag(value)

Getter

get_flag()


Default

false

Setter

set_flag(value)

Getter

get_flag()


Default

false

Setter

set_flag(value)

Getter

get_flag()

If true, the window can't be resized.


Default

true

Setter

set_visible(value)

Getter

is_visible()

If true, the window is visible.


  • bool wrap_controls

Default

false

Setter

set_wrap_controls(value)

Getter

is_wrapping_controls()

Method Descriptions

  • bool can_draw ( ) const

Returns whether the window is being drawn to the screen.


  • void child_controls_changed ( )


  • Vector2 get_contents_minimum_size ( ) const

Returns the combined minimum size from the child Control nodes of the window.


Returns true if the flag is set.


Returns layout direction and text writing direction.


Returns the window's size including its border.




  • float get_theme_default_base_scale ( ) const


  • Font get_theme_default_font ( ) const


  • int get_theme_default_font_size ( ) const


Returns the Font at name if the theme has theme_type.


Returns the font size at name if the theme has theme_type.




  • 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.




Returns true if Font with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if font size with name is in theme_type.

Returns false if the theme does not have theme_type.




  • void hide ( )


  • 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


  • bool is_using_font_oversampling ( ) const


  • 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_on_parent ( Rect2i parent_rect )


  • void request_attention ( )


Sets a specified window flag.


  • void set_ime_active ( bool active )


  • void set_ime_position ( Vector2i position )


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


  • void set_use_font_oversampling ( bool enable )


  • void show ( )

Theme Property Descriptions


  • int close_h_ofs

Default

18



  • int close_v_ofs

Default

18



  • int resize_margin

Default

4


  • int scaleborder_size

Default

4


Default

Color(0, 0, 0, 1)



  • int title_font_size

The size of the title font.


  • int title_height

Default

20


  • Color title_outline_modulate

Default

Color(1, 1, 1, 1)

The color of the title outline.


  • int title_outline_size

Default

0

The size of the title outline.