Class Window
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A node that creates a window. The window can either be a native system window or embedded inside another Window (see GuiEmbedSubwindows).
At runtime, Windows will not close automatically when requested. You need to handle it manually using the CloseRequested signal (this applies both to pressing the close button and clicking outside of a popup).
public class Window : Viewport, IDisposable
- Inheritance
-
Window
- Implements
- Derived
- Inherited Members
Constructors
Window()
public Window()
Fields
NotificationThemeChanged
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 ThemeTypeVariation 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.
public const long NotificationThemeChanged = 32
Field Value
NotificationVisibilityChanged
Emitted when Window's visibility changes, right before VisibilityChanged.
public const long NotificationVisibilityChanged = 30
Field Value
Properties
AlwaysOnTop
If true
, the window will be on top of all other windows. Does not work if Transient is enabled.
public bool AlwaysOnTop { get; set; }
Property Value
AutoTranslate
Toggles if any text should automatically change to its translated version depending on the current locale.
public bool AutoTranslate { get; set; }
Property Value
Borderless
If true
, the window will have no borders.
public bool Borderless { get; set; }
Property Value
ContentScaleAspect
Specifies how the content's aspect behaves when the Window is resized. The base aspect is determined by ContentScaleSize.
public Window.ContentScaleAspectEnum ContentScaleAspect { get; set; }
Property Value
ContentScaleFactor
Specifies the base scale of Window's content when its Size is equal to ContentScaleSize.
public float ContentScaleFactor { get; set; }
Property Value
ContentScaleMode
Specifies how the content is scaled when the Window is resized.
public Window.ContentScaleModeEnum ContentScaleMode { get; set; }
Property Value
ContentScaleSize
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.
public Vector2I ContentScaleSize { get; set; }
Property Value
ContentScaleStretch
The policy to use to determine the final scale factor for 2D elements. This affects how ContentScaleFactor is applied, in addition to the automatic scale factor determined by ContentScaleSize.
public Window.ContentScaleStretchEnum ContentScaleStretch { get; set; }
Property Value
CurrentScreen
The screen the window is currently on.
public int CurrentScreen { get; set; }
Property Value
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.
public bool Exclusive { get; set; }
Property Value
ExtendToTitle
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.
public bool ExtendToTitle { get; set; }
Property Value
InitialPosition
Specifies the initial type of position for the Window. See Window.WindowInitialPosition constants.
public Window.WindowInitialPosition InitialPosition { get; set; }
Property Value
KeepTitleVisible
If true
, the Window width is expanded to keep the title bar text fully visible.
public bool KeepTitleVisible { get; set; }
Property Value
MaxSize
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 MinSize.
public Vector2I MaxSize { get; set; }
Property Value
MinSize
If non-zero, the Window can't be resized to be smaller than this size.
Note: This property will be ignored in favor of GetContentsMinimumSize() if WrapControls is enabled and if its size is bigger.
public Vector2I MinSize { get; set; }
Property Value
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 GuiEmbedSubwindows is disabled in the main viewport.
public Window.ModeEnum Mode { get; set; }
Property Value
MousePassthrough
If true
, all mouse events will be passed to the underlying window of the same application. See also MousePassthroughPolygon.
Note: This property is implemented on Linux (X11), macOS and Windows.
Note: This property only works with native windows.
public bool MousePassthrough { get; set; }
Property Value
MousePassthroughPolygon
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.
GetNode<Window>("Window").MousePassthrough = GetNode<Path2D>("Path2D").Curve.GetBakedPoints();
// Set region, using Polygon2D node.
GetNode<Window>("Window").MousePassthrough = GetNode<Polygon2D>("Polygon2D").Polygon;
// Reset region to default.
GetNode<Window>("Window").MousePassthrough = new Vector2[] {};
Note: This property is ignored if MousePassthrough 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.
public Vector2[] MousePassthroughPolygon { get; set; }
Property Value
- Vector2[]
PopupWindow
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).
public bool PopupWindow { get; set; }
Property Value
Position
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 InitialPosition is set to Absolute.
public Vector2I Position { get; set; }
Property Value
Size
The window's size in pixels.
public Vector2I Size { get; set; }
Property Value
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.
public Theme Theme { get; set; }
Property Value
ThemeTypeVariation
The name of a theme type variation used by this Window to look up its own theme items. See ThemeTypeVariation for more details.
public StringName ThemeTypeVariation { get; set; }
Property Value
Title
public string Title { get; set; }
Property Value
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.
public bool Transient { get; set; }
Property Value
Transparent
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 TransparentBg is set to false
.
public bool Transparent { get; set; }
Property Value
Unfocusable
If true
, the Window can't be focused nor interacted with. It can still be visible.
public bool Unfocusable { get; set; }
Property Value
Unresizable
If true
, the window can't be resized. Minimize and maximize buttons are disabled.
public bool Unresizable { get; set; }
Property Value
Visible
If true
, the window is visible.
public bool Visible { get; set; }
Property Value
WrapControls
If true
, the window's size will automatically update when a child node is added or removed, ignoring MinSize if the new size is bigger.
If false
, you need to call ChildControlsChanged() manually.
public bool WrapControls { get; set; }
Property Value
Methods
AddThemeColorOverride(StringName, 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 RemoveThemeColorOverride(StringName).
See also GetThemeColor(StringName, StringName) and AddThemeColorOverride(StringName, Color) for more details.
public void AddThemeColorOverride(StringName name, Color color)
Parameters
name
StringNamecolor
Color
AddThemeConstantOverride(StringName, int)
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 RemoveThemeConstantOverride(StringName).
See also GetThemeConstant(StringName, StringName).
public void AddThemeConstantOverride(StringName name, int constant)
Parameters
name
StringNameconstant
int
AddThemeFontOverride(StringName, 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 RemoveThemeFontOverride(StringName).
See also GetThemeFont(StringName, StringName).
public void AddThemeFontOverride(StringName name, Font font)
Parameters
name
StringNamefont
Font
AddThemeFontSizeOverride(StringName, int)
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 RemoveThemeFontSizeOverride(StringName).
See also GetThemeFontSize(StringName, StringName).
public void AddThemeFontSizeOverride(StringName name, int fontSize)
Parameters
name
StringNamefontSize
int
AddThemeIconOverride(StringName, Texture2D)
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 RemoveThemeIconOverride(StringName).
See also GetThemeIcon(StringName, StringName).
public void AddThemeIconOverride(StringName name, Texture2D texture)
Parameters
name
StringNametexture
Texture2D
AddThemeStyleboxOverride(StringName, 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 RemoveThemeStyleboxOverride(StringName).
See also GetThemeStylebox(StringName, StringName) and AddThemeStyleboxOverride(StringName, StyleBox) for more details.
public void AddThemeStyleboxOverride(StringName name, StyleBox stylebox)
Parameters
name
StringNamestylebox
StyleBox
BeginBulkThemeOverride()
Prevents *_theme_*_override
methods from emitting NotificationThemeChanged until EndBulkThemeOverride() is called.
public void BeginBulkThemeOverride()
CanDraw()
Returns whether the window is being drawn to the screen.
public bool CanDraw()
Returns
ChildControlsChanged()
public void ChildControlsChanged()
EndBulkThemeOverride()
Ends a bulk theme override update. See BeginBulkThemeOverride().
public void EndBulkThemeOverride()
GetContentsMinimumSize()
Returns the combined minimum size from the child Control nodes of the window. Use ChildControlsChanged() to update it when child nodes have changed.
The value returned by this method can be overridden with _GetContentsMinimumSize().
public Vector2 GetContentsMinimumSize()
Returns
GetLayoutDirection()
Returns layout direction and text writing direction.
public Window.LayoutDirection GetLayoutDirection()
Returns
GetPositionWithDecorations()
Returns the window's position including its border.
public Vector2I GetPositionWithDecorations()
Returns
GetSizeWithDecorations()
Returns the window's size including its border.
public Vector2I GetSizeWithDecorations()
Returns
GetThemeColor(StringName, StringName)
Returns a Color from the first matching Theme in the tree if that Theme has a color item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for more details.
public Color GetThemeColor(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetThemeConstant(StringName, StringName)
Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for more details.
public int GetThemeConstant(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetThemeDefaultBaseScale()
Returns the default base scale value from the first matching Theme in the tree if that Theme has a valid DefaultBaseScale value.
See GetThemeColor(StringName, StringName) for details.
public float GetThemeDefaultBaseScale()
Returns
GetThemeDefaultFont()
Returns the default font from the first matching Theme in the tree if that Theme has a valid DefaultFont value.
See GetThemeColor(StringName, StringName) for details.
public Font GetThemeDefaultFont()
Returns
GetThemeDefaultFontSize()
Returns the default font size value from the first matching Theme in the tree if that Theme has a valid DefaultFontSize value.
See GetThemeColor(StringName, StringName) for details.
public int GetThemeDefaultFontSize()
Returns
GetThemeFont(StringName, StringName)
Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public Font GetThemeFont(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetThemeFontSize(StringName, StringName)
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 themeType
.
See GetThemeColor(StringName, StringName) for details.
public int GetThemeFontSize(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetThemeIcon(StringName, StringName)
Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public Texture2D GetThemeIcon(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetThemeStylebox(StringName, StringName)
Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public StyleBox GetThemeStylebox(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
GetWindowId()
Returns the ID of the window.
public int GetWindowId()
Returns
GrabFocus()
Causes the window to grab focus, allowing it to receive user input.
public void GrabFocus()
HasFocus()
Returns true
if the window is focused.
public bool HasFocus()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
HasThemeColor(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has a color item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeColor(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeColorOverride(StringName)
Returns true
if there is a local override for a theme Color with the specified name
in this Control node.
public bool HasThemeColorOverride(StringName name)
Parameters
name
StringName
Returns
HasThemeConstant(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has a constant item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeConstant(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeConstantOverride(StringName)
Returns true
if there is a local override for a theme constant with the specified name
in this Control node.
public bool HasThemeConstantOverride(StringName name)
Parameters
name
StringName
Returns
HasThemeFont(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has a font item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeFont(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeFontOverride(StringName)
Returns true
if there is a local override for a theme Font with the specified name
in this Control node.
public bool HasThemeFontOverride(StringName name)
Parameters
name
StringName
Returns
HasThemeFontSize(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has a font size item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeFontSize(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeFontSizeOverride(StringName)
Returns true
if there is a local override for a theme font size with the specified name
in this Control node.
public bool HasThemeFontSizeOverride(StringName name)
Parameters
name
StringName
Returns
HasThemeIcon(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has an icon item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeIcon(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeIconOverride(StringName)
Returns true
if there is a local override for a theme icon with the specified name
in this Control node.
public bool HasThemeIconOverride(StringName name)
Parameters
name
StringName
Returns
HasThemeStylebox(StringName, StringName)
Returns true
if there is a matching Theme in the tree that has a stylebox item with the specified name
and themeType
.
See GetThemeColor(StringName, StringName) for details.
public bool HasThemeStylebox(StringName name, StringName themeType = null)
Parameters
name
StringNamethemeType
StringName
Returns
HasThemeStyleboxOverride(StringName)
Returns true
if there is a local override for a theme StyleBox with the specified name
in this Control node.
public bool HasThemeStyleboxOverride(StringName name)
Parameters
name
StringName
Returns
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().
public void Hide()
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsEmbedded()
Returns true
if the window is currently embedded in another window.
public bool IsEmbedded()
Returns
IsLayoutRtl()
Returns true
if layout is right-to-left.
public bool IsLayoutRtl()
Returns
IsMaximizeAllowed()
Returns true
if the window can be maximized (the maximize button is enabled).
public bool IsMaximizeAllowed()
Returns
IsUsingFontOversampling()
Returns true
if font oversampling is enabled. See SetUseFontOversampling(bool).
public bool IsUsingFontOversampling()
Returns
MoveToCenter()
Centers a native window on the current screen and an embedded window on its embedder Viewport.
public void MoveToCenter()
MoveToForeground()
Moves the Window on top of other windows and focuses it.
public void MoveToForeground()
Popup(Rect2I?)
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.
public void Popup(Rect2I? rect = null)
Parameters
rect
Rect2I?If the parameter is null, then the default value is
new Rect2I(new Vector2I(0, 0), new Vector2I(0, 0))
.
PopupCentered(Vector2I?)
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.
public void PopupCentered(Vector2I? minsize = null)
Parameters
minsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.
PopupCenteredClamped(Vector2I?, float)
Popups the Window centered inside its parent Window. fallbackRatio
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.
public void PopupCenteredClamped(Vector2I? minsize = null, float fallbackRatio = 0.75)
Parameters
minsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.fallbackRatio
float
PopupCenteredRatio(float)
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.
public void PopupCenteredRatio(float ratio = 0.8)
Parameters
ratio
float
PopupExclusive(Node, Rect2I?)
Attempts to parent this dialog to the last exclusive window relative to fromNode
, and then calls Popup(Rect2I?) on it. The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool) and GetLastExclusiveWindow().
public void PopupExclusive(Node fromNode, Rect2I? rect = null)
Parameters
fromNode
Noderect
Rect2I?If the parameter is null, then the default value is
new Rect2I(new Vector2I(0, 0), new Vector2I(0, 0))
.
PopupExclusiveCentered(Node, Vector2I?)
Attempts to parent this dialog to the last exclusive window relative to fromNode
, and then calls PopupCentered(Vector2I?) on it. The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool) and GetLastExclusiveWindow().
public void PopupExclusiveCentered(Node fromNode, Vector2I? minsize = null)
Parameters
fromNode
Nodeminsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.
PopupExclusiveCenteredClamped(Node, Vector2I?, float)
Attempts to parent this dialog to the last exclusive window relative to fromNode
, and then calls PopupCenteredClamped(Vector2I?, float) on it. The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool) and GetLastExclusiveWindow().
public void PopupExclusiveCenteredClamped(Node fromNode, Vector2I? minsize = null, float fallbackRatio = 0.75)
Parameters
fromNode
Nodeminsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.fallbackRatio
float
PopupExclusiveCenteredRatio(Node, float)
Attempts to parent this dialog to the last exclusive window relative to fromNode
, and then calls PopupCenteredRatio(float) on it. The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool) and GetLastExclusiveWindow().
public void PopupExclusiveCenteredRatio(Node fromNode, float ratio = 0.8)
Parameters
PopupExclusiveOnParent(Node, Rect2I)
Attempts to parent this dialog to the last exclusive window relative to fromNode
, and then calls PopupOnParent(Rect2I) on it. The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool) and GetLastExclusiveWindow().
public void PopupExclusiveOnParent(Node fromNode, Rect2I parentRect)
Parameters
PopupOnParent(Rect2I)
Popups the Window with a position shifted by parent Window's position. If the Window is embedded, has the same effect as Popup(Rect2I?).
public void PopupOnParent(Rect2I parentRect)
Parameters
parentRect
Rect2I
RemoveThemeColorOverride(StringName)
Removes a local override for a theme Color with the specified name
previously added by AddThemeColorOverride(StringName, Color) or via the Inspector dock.
public void RemoveThemeColorOverride(StringName name)
Parameters
name
StringName
RemoveThemeConstantOverride(StringName)
Removes a local override for a theme constant with the specified name
previously added by AddThemeConstantOverride(StringName, int) or via the Inspector dock.
public void RemoveThemeConstantOverride(StringName name)
Parameters
name
StringName
RemoveThemeFontOverride(StringName)
Removes a local override for a theme Font with the specified name
previously added by AddThemeFontOverride(StringName, Font) or via the Inspector dock.
public void RemoveThemeFontOverride(StringName name)
Parameters
name
StringName
RemoveThemeFontSizeOverride(StringName)
Removes a local override for a theme font size with the specified name
previously added by AddThemeFontSizeOverride(StringName, int) or via the Inspector dock.
public void RemoveThemeFontSizeOverride(StringName name)
Parameters
name
StringName
RemoveThemeIconOverride(StringName)
Removes a local override for a theme icon with the specified name
previously added by AddThemeIconOverride(StringName, Texture2D) or via the Inspector dock.
public void RemoveThemeIconOverride(StringName name)
Parameters
name
StringName
RemoveThemeStyleboxOverride(StringName)
Removes a local override for a theme StyleBox with the specified name
previously added by AddThemeStyleboxOverride(StringName, StyleBox) or via the Inspector dock.
public void RemoveThemeStyleboxOverride(StringName name)
Parameters
name
StringName
RequestAttention()
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.
public void RequestAttention()
ResetSize()
Resets the size to the minimum size, which is the max of MinSize and (if WrapControls is enabled) GetContentsMinimumSize(). This is equivalent to calling set_size(Vector2i())
(or any size below the minimum).
public void ResetSize()
SetImeActive(bool)
If active
is true
, enables system's native IME (Input Method Editor).
public void SetImeActive(bool active)
Parameters
active
bool
SetImePosition(Vector2I)
Moves IME to the given position.
public void SetImePosition(Vector2I position)
Parameters
position
Vector2I
SetLayoutDirection(LayoutDirection)
Sets layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew).
public void SetLayoutDirection(Window.LayoutDirection direction)
Parameters
direction
Window.LayoutDirection
SetUnparentWhenInvisible(bool)
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 QueueFree() to free the window if it's not parented.
public void SetUnparentWhenInvisible(bool unparent)
Parameters
unparent
bool
SetUseFontOversampling(bool)
Enables font oversampling. This makes fonts look better when they are scaled up.
public void SetUseFontOversampling(bool enable)
Parameters
enable
bool
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(Rect2I?)).
public void Show()
_GetContentsMinimumSize()
Virtual method to be implemented by the user. Overrides the value returned by GetContentsMinimumSize().
public virtual Vector2 _GetContentsMinimumSize()
Returns
Events
AboutToPopup
Emitted right after Popup(Rect2I?) call, before the Window appears or does anything.
public event Action AboutToPopup
Event Type
CloseRequested
Emitted when the Window's close button is pressed or when PopupWindow is enabled and user clicks outside the window.
This signal can be used to handle window closing, e.g. by connecting it to Hide().
public event Action CloseRequested
Event Type
DpiChanged
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.
public event Action DpiChanged
Event Type
FilesDropped
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 GuiEmbedSubwindows 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)
public event Window.FilesDroppedEventHandler FilesDropped
Event Type
FocusEntered
Emitted when the Window gains focus.
public event Action FocusEntered
Event Type
FocusExited
Emitted when the Window loses its focus.
public event Action FocusExited
Event Type
GoBackRequested
Emitted when a go back request is sent (e.g. pressing the "Back" button on Android), right after NotificationWMGoBackRequest.
public event Action GoBackRequested
Event Type
MouseEntered
Emitted when the mouse cursor enters the Window's visible area, that is not occluded behind other Controls or windows, provided its GuiDisableInput is false
and regardless if it's currently focused or not.
public event Action MouseEntered
Event Type
MouseExited
Emitted when the mouse cursor leaves the Window's visible area, that is not occluded behind other Controls or windows, provided its GuiDisableInput is false
and regardless if it's currently focused or not.
public event Action MouseExited
Event Type
ThemeChanged
Emitted when the NotificationThemeChanged notification is sent.
public event Action ThemeChanged
Event Type
TitlebarChanged
Emitted when window title bar decorations are changed, e.g. macOS window enter/exit full screen mode, or extend-to-title flag is changed.
public event Action TitlebarChanged
Event Type
VisibilityChanged
Emitted when Window is made visible or disappears.
public event Action VisibilityChanged
Event Type
WindowInput
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.
public event Window.WindowInputEventHandler WindowInput