Up to date
This page is up to date for Godot 4.1
.
If you still find outdated information, please open an issue.
Window¶
Inherits: Viewport < Node < Object
Inherited By: AcceptDialog, Popup
Base class for all windows, dialogs, and popups.
Description¶
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).
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
Theme Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Signals¶
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 area, regardless if it's currently focused or not.
mouse_exited ( )
Emitted when the mouse cursor exits the Window's area (including when it's hovered over another window on top of this one).
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 i