Class DisplayServerInstance
- Namespace
- Godot
- Assembly
- GodotSharp.dll
DisplayServer handles everything related to window management. It is separated from OS as a single operating system may support multiple display servers.
Headless mode: Starting the engine with the --headless
command line argument disables all rendering and window management functions. Most functions from DisplayServer will return dummy values in this case.
[GodotClassName("DisplayServer")]
public class DisplayServerInstance : GodotObject, IDisposable
- Inheritance
-
DisplayServerInstance
- Implements
- Inherited Members
Methods
ClipboardGet()
Returns the user's clipboard as a string if possible.
public string ClipboardGet()
Returns
ClipboardGetImage()
Returns the user's clipboard as an image if possible.
public Image ClipboardGetImage()
Returns
ClipboardGetPrimary()
Returns the user's primary clipboard as a string if possible. This is the clipboard that is set when the user selects text in any application, rather than when pressing Ctrl + C. The clipboard data can then be pasted by clicking the middle mouse button in any application that supports the primary clipboard mechanism.
Note: This method is only implemented on Linux (X11).
public string ClipboardGetPrimary()
Returns
ClipboardHas()
Returns true
if there is a text content on the user's clipboard.
public bool ClipboardHas()
Returns
ClipboardHasImage()
Returns true
if there is an image content on the user's clipboard.
public bool ClipboardHasImage()
Returns
ClipboardSet(string)
Sets the user's clipboard content to the given string.
public void ClipboardSet(string clipboard)
Parameters
clipboard
string
ClipboardSetPrimary(string)
Sets the user's primary clipboard content to the given string. This is the clipboard that is set when the user selects text in any application, rather than when pressing Ctrl + C. The clipboard data can then be pasted by clicking the middle mouse button in any application that supports the primary clipboard mechanism.
Note: This method is only implemented on Linux (X11).
public void ClipboardSetPrimary(string clipboardPrimary)
Parameters
clipboardPrimary
string
CursorGetShape()
Returns the default mouse cursor shape set by CursorSetShape(CursorShape).
public DisplayServer.CursorShape CursorGetShape()
Returns
CursorSetCustomImage(Resource, CursorShape, Vector2?)
Sets a custom mouse cursor image for the defined shape
. This means the user's operating system and mouse cursor theme will no longer influence the mouse cursor's appearance. The image must be 256x256
or smaller for correct appearance. hotspot
can optionally be set to define the area where the cursor will click. By default, hotspot
is set to Vector2(0, 0)
, which is the top-left corner of the image. See also CursorSetShape(CursorShape).
public void CursorSetCustomImage(Resource cursor, DisplayServer.CursorShape shape = CursorShape.Arrow, Vector2? hotspot = null)
Parameters
cursor
Resourceshape
DisplayServer.CursorShapehotspot
Vector2?If the parameter is null, then the default value is
new Vector2(0, 0)
.
CursorSetShape(CursorShape)
Sets the default mouse cursor shape. The cursor's appearance will vary depending on the user's operating system and mouse cursor theme. See also CursorGetShape() and CursorSetCustomImage(Resource, CursorShape, Vector2?).
public void CursorSetShape(DisplayServer.CursorShape shape)
Parameters
shape
DisplayServer.CursorShape
DialogInputText(string, string, string, Callable)
Shows a text input dialog which uses the operating system's native look-and-feel. callback
will be called with a string argument equal to the text field's contents when the dialog is closed for any reason.
Note: This method is implemented only on macOS.
public Error DialogInputText(string title, string description, string existingText, Callable callback)
Parameters
Returns
DialogShow(string, string, string[], Callable)
Shows a text dialog which uses the operating system's native look-and-feel. callback
will be called when the dialog is closed for any reason.
Note: This method is implemented only on macOS.
public Error DialogShow(string title, string description, string[] buttons, Callable callback)
Parameters
Returns
EnableForStealingFocus(long)
Allows the processId
PID to steal focus from this window. In other words, this disables the operating system's focus stealing protection for the specified PID.
Note: This method is implemented only on Windows.
public void EnableForStealingFocus(long processId)
Parameters
processId
long
FileDialogShow(string, string, string, bool, FileDialogMode, string[], Callable)
Displays OS native dialog for selecting files or directories in the file system.
Callbacks have the following arguments: bool status, PackedStringArray selected_paths, int selected_filter_index
.
Note: This method is implemented if the display server has the NativeDialog feature.
Note: This method is implemented on Linux, Windows and macOS.
Note:
currentDirectory
might be ignored.
Note: On Linux, showHidden
is ignored.
Note: On macOS, native file dialogs have no title.
Note: On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use GetGrantedPermissions() to get a list of saved bookmarks.
public Error FileDialogShow(string title, string currentDirectory, string fileName, bool showHidden, DisplayServer.FileDialogMode mode, string[] filters, Callable callback)
Parameters
title
stringcurrentDirectory
stringfileName
stringshowHidden
boolmode
DisplayServer.FileDialogModefilters
string[]callback
Callable
Returns
ForceProcessAndDropEvents()
Forces window manager processing while ignoring all InputEvents. See also ProcessEvents().
Note: This method is implemented on Windows and macOS.
public void ForceProcessAndDropEvents()
GetAccentColor()
Returns OS theme accent color. Returns Color(0, 0, 0, 0)
, if accent color is unknown.
Note: This method is implemented on macOS and Windows.
public Color GetAccentColor()
Returns
GetDisplayCutouts()
Returns an Array of Rect2, each of which is the bounding rectangle for a display cutout or notch. These are non-functional areas on edge-to-edge screens used by cameras and sensors. Returns an empty array if the device does not have cutouts. See also GetDisplaySafeArea().
Note: Currently only implemented on Android. Other platforms will return an empty array even if they do have display cutouts or notches.
public Array<Rect2> GetDisplayCutouts()
Returns
GetDisplaySafeArea()
Returns the unobscured area of the display where interactive controls should be rendered. See also GetDisplayCutouts().
public Rect2I GetDisplaySafeArea()
Returns
GetKeyboardFocusScreen()
Returns the index of the screen containing the window with the keyboard focus, or the primary screen if there's no focused window.
public int GetKeyboardFocusScreen()
Returns
GetName()
Returns the name of the DisplayServer currently in use. Most operating systems only have a single DisplayServer, but Linux has access to more than one DisplayServer (although only X11 is currently implemented in Godot).
The names of built-in display servers are Windows
, macOS
, X11
(Linux), Android
, iOS
, web
(HTML5) and headless
(when started with the --headless
command line argument).
public string GetName()
Returns
GetPrimaryScreen()
Returns index of the primary screen.
public int GetPrimaryScreen()
Returns
GetScreenCount()
Returns the number of displays available.
public int GetScreenCount()
Returns
GetScreenFromRect(Rect2)
Returns index of the screen which contains specified rectangle.
public int GetScreenFromRect(Rect2 rect)
Parameters
rect
Rect2
Returns
GetSwapCancelOk()
Returns true
if positions of OK and Cancel buttons are swapped in dialogs. This is enabled by default on Windows to follow interface conventions, and be toggled by changing ProjectSettings.gui/common/swap_cancel_ok
.
Note: This doesn't affect native dialogs such as the ones spawned by DialogShow(string, string, string[], Callable).
public bool GetSwapCancelOk()
Returns
GetWindowAtScreenPosition(Vector2I)
Returns the ID of the window at the specified screen position
(in pixels). On multi-monitor setups, the screen position is relative to the virtual desktop area. On multi-monitor setups with different screen resolutions or orientations, the origin may be located outside any display like this:
* (0, 0) +-------+
| |
+-------------+ | |
| | | |
| | | |
+-------------+ +-------+
public int GetWindowAtScreenPosition(Vector2I position)
Parameters
position
Vector2I
Returns
GetWindowList()
Returns the list of Godot window IDs belonging to this process.
Note: Native dialogs are not included in this list.
public int[] GetWindowList()
Returns
- int[]
GlobalMenuAddCheckItem(string, string, Callable, Callable, Variant, Key, int)
Adds a new checkable item with text label
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddCheckItem(string menuRoot, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddIconCheckItem(string, Texture2D, string, Callable, Callable, Variant, Key, int)
Adds a new checkable item with text label
and icon icon
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddIconCheckItem(string menuRoot, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringicon
Texture2Dlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddIconItem(string, Texture2D, string, Callable, Callable, Variant, Key, int)
Adds a new item with text label
and icon icon
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddIconItem(string menuRoot, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringicon
Texture2Dlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddIconRadioCheckItem(string, Texture2D, string, Callable, Callable, Variant, Key, int)
Adds a new radio-checkable item with text label
and icon icon
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See GlobalMenuSetItemChecked(string, int, bool) for more info on how to control it.
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddIconRadioCheckItem(string menuRoot, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringicon
Texture2Dlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddItem(string, string, Callable, Callable, Variant, Key, int)
Adds a new item with text label
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddItem(string menuRoot, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddMultistateItem(string, string, int, int, Callable, Callable, Variant, Key, int)
Adds a new item with text label
to the global menu with ID menuRoot
.
Contrarily to normal binary items, multistate items can have more than two states, as defined by maxStates
. Each press or activate of the item will increase the state by one. The default value is defined by defaultState
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: By default, there's no indication of the current item state, it should be changed manually.
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddMultistateItem(string menuRoot, string label, int maxStates, int defaultState, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringlabel
stringmaxStates
intdefaultState
intcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddRadioCheckItem(string, string, Callable, Callable, Variant, Key, int)
Adds a new radio-checkable item with text label
to the global menu with ID menuRoot
.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
An accelerator
can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator
is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See GlobalMenuSetItemChecked(string, int, bool) for more info on how to control it.
Note: The callback
and keyCallback
Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddRadioCheckItem(string menuRoot, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1)
Parameters
menuRoot
stringlabel
stringcallback
CallablekeyCallback
Callabletag
Variantaccelerator
Keyindex
int
Returns
GlobalMenuAddSeparator(string, int)
Adds a separator between items to the global menu with ID menuRoot
. Separators also occupy an index.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddSeparator(string menuRoot, int index = -1)
Parameters
Returns
GlobalMenuAddSubmenuItem(string, string, string, int)
Adds an item that will act as a submenu of the global menu menuRoot
. The submenu
argument is the ID of the global menu root that will be shown when the item is clicked.
Returns index of the inserted item, it's not guaranteed to be the same as index
value.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public int GlobalMenuAddSubmenuItem(string menuRoot, string label, string submenu, int index = -1)
Parameters
Returns
GlobalMenuClear(string)
Removes all items from the global menu with ID menuRoot
.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
public void GlobalMenuClear(string menuRoot)
Parameters
menuRoot
string
GlobalMenuGetItemAccelerator(string, int)
Returns the accelerator of the item at index idx
. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
Note: This method is implemented only on macOS.
public Key GlobalMenuGetItemAccelerator(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemCallback(string, int)
Returns the callback of the item at index idx
.
Note: This method is implemented only on macOS.
public Callable GlobalMenuGetItemCallback(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemCount(string)
Returns number of items in the global menu with ID menuRoot
.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemCount(string menuRoot)
Parameters
menuRoot
string
Returns
GlobalMenuGetItemIcon(string, int)
Returns the icon of the item at index idx
.
Note: This method is implemented only on macOS.
public Texture2D GlobalMenuGetItemIcon(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemIndentationLevel(string, int)
Returns the horizontal offset of the item at the given idx
.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemIndentationLevel(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemIndexFromTag(string, Variant)
Returns the index of the item with the specified tag
. Index is automatically assigned to each item by the engine. Index can not be set manually.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemIndexFromTag(string menuRoot, Variant tag)
Parameters
Returns
GlobalMenuGetItemIndexFromText(string, string)
Returns the index of the item with the specified text
. Index is automatically assigned to each item by the engine. Index can not be set manually.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemIndexFromText(string menuRoot, string text)
Parameters
Returns
GlobalMenuGetItemKeyCallback(string, int)
Returns the callback of the item accelerator at index idx
.
Note: This method is implemented only on macOS.
public Callable GlobalMenuGetItemKeyCallback(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemMaxStates(string, int)
Returns number of states of a multistate item. See GlobalMenuAddMultistateItem(string, string, int, int, Callable, Callable, Variant, Key, int) for details.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemMaxStates(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemState(string, int)
Returns the state of a multistate item. See GlobalMenuAddMultistateItem(string, string, int, int, Callable, Callable, Variant, Key, int) for details.
Note: This method is implemented only on macOS.
public int GlobalMenuGetItemState(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemSubmenu(string, int)
Returns the submenu ID of the item at index idx
. See GlobalMenuAddSubmenuItem(string, string, string, int) for more info on how to add a submenu.
Note: This method is implemented only on macOS.
public string GlobalMenuGetItemSubmenu(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemTag(string, int)
Returns the metadata of the specified item, which might be of any type. You can set it with GlobalMenuSetItemTag(string, int, Variant), which provides a simple way of assigning context data to items.
Note: This method is implemented only on macOS.
public Variant GlobalMenuGetItemTag(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemText(string, int)
Returns the text of the item at index idx
.
Note: This method is implemented only on macOS.
public string GlobalMenuGetItemText(string menuRoot, int idx)
Parameters
Returns
GlobalMenuGetItemTooltip(string, int)
Returns the tooltip associated with the specified index idx
.
Note: This method is implemented only on macOS.
public string GlobalMenuGetItemTooltip(string menuRoot, int idx)
Parameters
Returns
GlobalMenuIsItemCheckable(string, int)
Returns true
if the item at index idx
is checkable in some way, i.e. if it has a checkbox or radio button.
Note: This method is implemented only on macOS.
public bool GlobalMenuIsItemCheckable(string menuRoot, int idx)
Parameters
Returns
GlobalMenuIsItemChecked(string, int)
Returns true
if the item at index idx
is checked.
Note: This method is implemented only on macOS.
public bool GlobalMenuIsItemChecked(string menuRoot, int idx)
Parameters
Returns
GlobalMenuIsItemDisabled(string, int)
Returns true
if the item at index idx
is disabled. When it is disabled it can't be selected, or its action invoked.
See GlobalMenuSetItemDisabled(string, int, bool) for more info on how to disable an item.
Note: This method is implemented only on macOS.
public bool GlobalMenuIsItemDisabled(string menuRoot, int idx)
Parameters
Returns
GlobalMenuIsItemHidden(string, int)
Returns true
if the item at index idx
is hidden.
See GlobalMenuSetItemHidden(string, int, bool) for more info on how to hide an item.
Note: This method is implemented only on macOS.
public bool GlobalMenuIsItemHidden(string menuRoot, int idx)
Parameters
Returns
GlobalMenuIsItemRadioCheckable(string, int)
Returns true
if the item at index idx
has radio button-style checkability.
Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
Note: This method is implemented only on macOS.
public bool GlobalMenuIsItemRadioCheckable(string menuRoot, int idx)
Parameters
Returns
GlobalMenuRemoveItem(string, int)
Removes the item at index idx
from the global menu menuRoot
.
Note: The indices of items after the removed item will be shifted by one.
Note: This method is implemented only on macOS.
public void GlobalMenuRemoveItem(string menuRoot, int idx)
Parameters
GlobalMenuSetItemAccelerator(string, int, Key)
Sets the accelerator of the item at index idx
. keycode
can be a single Key, or a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A
(Ctrl + A).
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemAccelerator(string menuRoot, int idx, Key keycode)
Parameters
GlobalMenuSetItemCallback(string, int, Callable)
Sets the callback of the item at index idx
. Callback is emitted when an item is pressed.
Note: The callback
Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag
parameter when the menu item was created.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemCallback(string menuRoot, int idx, Callable callback)
Parameters
GlobalMenuSetItemCheckable(string, int, bool)
Sets whether the item at index idx
has a checkbox. If false
, sets the type of the item to plain text.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemCheckable(string menuRoot, int idx, bool checkable)
Parameters
GlobalMenuSetItemChecked(string, int, bool)
Sets the checkstate status of the item at index idx
.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemChecked(string menuRoot, int idx, bool @checked)
Parameters
GlobalMenuSetItemDisabled(string, int, bool)
Enables/disables the item at index idx
. When it is disabled, it can't be selected and its action can't be invoked.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemDisabled(string menuRoot, int idx, bool disabled)
Parameters
GlobalMenuSetItemHidden(string, int, bool)
Hides/shows the item at index idx
. When it is hidden, an item does not appear in a menu and its action cannot be invoked.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemHidden(string menuRoot, int idx, bool hidden)
Parameters
GlobalMenuSetItemHoverCallbacks(string, int, Callable)
Sets the callback of the item at index idx
. The callback is emitted when an item is hovered.
Note: The callback
Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag
parameter when the menu item was created.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemHoverCallbacks(string menuRoot, int idx, Callable callback)
Parameters
GlobalMenuSetItemIcon(string, int, Texture2D)
Replaces the Texture2D icon of the specified idx
.
Note: This method is implemented only on macOS.
Note: This method is not supported by macOS "_dock" menu items.
public void GlobalMenuSetItemIcon(string menuRoot, int idx, Texture2D icon)
Parameters
GlobalMenuSetItemIndentationLevel(string, int, int)
Sets the horizontal offset of the item at the given idx
.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemIndentationLevel(string menuRoot, int idx, int level)
Parameters
GlobalMenuSetItemKeyCallback(string, int, Callable)
Sets the callback of the item at index idx
. Callback is emitted when its accelerator is activated.
Note: The keyCallback
Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag
parameter when the menu item was created.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemKeyCallback(string menuRoot, int idx, Callable keyCallback)
Parameters
GlobalMenuSetItemMaxStates(string, int, int)
Sets number of state of a multistate item. See GlobalMenuAddMultistateItem(string, string, int, int, Callable, Callable, Variant, Key, int) for details.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemMaxStates(string menuRoot, int idx, int maxStates)
Parameters
GlobalMenuSetItemRadioCheckable(string, int, bool)
Sets the type of the item at the specified index idx
to radio button. If false
, sets the type of the item to plain text.
Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemRadioCheckable(string menuRoot, int idx, bool checkable)
Parameters
GlobalMenuSetItemState(string, int, int)
Sets the state of a multistate item. See GlobalMenuAddMultistateItem(string, string, int, int, Callable, Callable, Variant, Key, int) for details.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemState(string menuRoot, int idx, int state)
Parameters
GlobalMenuSetItemSubmenu(string, int, string)
Sets the submenu of the item at index idx
. The submenu is the ID of a global menu root that would be shown when the item is clicked.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemSubmenu(string menuRoot, int idx, string submenu)
Parameters
GlobalMenuSetItemTag(string, int, Variant)
Sets the metadata of an item, which may be of any type. You can later get it with GlobalMenuGetItemTag(string, int), which provides a simple way of assigning context data to items.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemTag(string menuRoot, int idx, Variant tag)
Parameters
GlobalMenuSetItemText(string, int, string)
Sets the text of the item at index idx
.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemText(string menuRoot, int idx, string text)
Parameters
GlobalMenuSetItemTooltip(string, int, string)
Sets the string tooltip of the item at the specified index idx
.
Note: This method is implemented only on macOS.
public void GlobalMenuSetItemTooltip(string menuRoot, int idx, string tooltip)
Parameters
GlobalMenuSetPopupCallbacks(string, Callable, Callable)
Registers callables to emit when the menu is respectively about to show or closed.
public void GlobalMenuSetPopupCallbacks(string menuRoot, Callable openCallback, Callable closeCallback)
Parameters
HasFeature(Feature)
Returns true
if the specified feature
is supported by the current DisplayServer, false
otherwise.
public bool HasFeature(DisplayServer.Feature feature)
Parameters
feature
DisplayServer.Feature
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
ImeGetSelection()
Returns the text selection in the Input Method Editor composition string, with the Vector2I's x
component being the caret position and y
being the length of the selection.
Note: This method is implemented only on macOS.
public Vector2I ImeGetSelection()
Returns
ImeGetText()
Returns the composition string contained within the Input Method Editor window.
Note: This method is implemented only on macOS.
public string ImeGetText()
Returns
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
IsDarkMode()
Returns true
if OS is using dark mode.
Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11).
public bool IsDarkMode()
Returns
IsDarkModeSupported()
Returns true
if OS supports dark mode.
Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11).
public bool IsDarkModeSupported()
Returns
IsTouchscreenAvailable()
Returns true
if touch events are available (Android or iOS), the capability is detected on the Web platform or if ProjectSettings.input_devices/pointing/emulate_touch_from_mouse
is true
.
public bool IsTouchscreenAvailable()
Returns
KeyboardGetCurrentLayout()
Returns active keyboard layout index.
Note: This method is implemented on Linux (X11), macOS and Windows.
public int KeyboardGetCurrentLayout()
Returns
KeyboardGetKeycodeFromPhysical(Key)
Converts a physical (US QWERTY) keycode
to one in the active keyboard layout.
Note: This method is implemented on Linux (X11), macOS and Windows.
public Key KeyboardGetKeycodeFromPhysical(Key keycode)
Parameters
keycode
Key
Returns
KeyboardGetLabelFromPhysical(Key)
Converts a physical (US QWERTY) keycode
to localized label printed on the key in the active keyboard layout.
Note: This method is implemented on Linux (X11), macOS and Windows.
public Key KeyboardGetLabelFromPhysical(Key keycode)
Parameters
keycode
Key
Returns
KeyboardGetLayoutCount()
Returns the number of keyboard layouts.
Note: This method is implemented on Linux (X11), macOS and Windows.
public int KeyboardGetLayoutCount()
Returns
KeyboardGetLayoutLanguage(int)
Returns the ISO-639/BCP-47 language code of the keyboard layout at position index
.
Note: This method is implemented on Linux (X11), macOS and Windows.
public string KeyboardGetLayoutLanguage(int index)
Parameters
index
int
Returns
KeyboardGetLayoutName(int)
Returns the localized name of the keyboard layout at position index
.
Note: This method is implemented on Linux (X11), macOS and Windows.
public string KeyboardGetLayoutName(int index)
Parameters
index
int
Returns
KeyboardSetCurrentLayout(int)
Sets the active keyboard layout.
Note: This method is implemented on Linux (X11), macOS and Windows.
public void KeyboardSetCurrentLayout(int index)
Parameters
index
int
MouseGetButtonState()
Returns the current state of mouse buttons (whether each button is pressed) as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. Equivalent to GetMouseButtonMask().
public MouseButtonMask MouseGetButtonState()
Returns
MouseGetMode()
Returns the current mouse mode. See also MouseSetMode(MouseMode).
public DisplayServer.MouseMode MouseGetMode()
Returns
MouseGetPosition()
Returns the mouse cursor's current position in screen coordinates.
public Vector2I MouseGetPosition()
Returns
MouseSetMode(MouseMode)
Sets the current mouse mode. See also MouseGetMode().
public void MouseSetMode(DisplayServer.MouseMode mouseMode)
Parameters
mouseMode
DisplayServer.MouseMode
ProcessEvents()
Perform window manager processing, including input flushing. See also ForceProcessAndDropEvents(), FlushBufferedEvents() and UseAccumulatedInput.
public void ProcessEvents()
ScreenGetDpi(int)
Returns the dots per inch density of the specified screen. If screen
is ScreenOfMainWindow (the default value), a screen with the main window will be used.
Note: On macOS, returned value is inaccurate if fractional display scaling mode is used.
Note: On Android devices, the actual screen densities are grouped into six generalized densities:
ldpi - 120 dpi
mdpi - 160 dpi
hdpi - 240 dpi
xhdpi - 320 dpi
xxhdpi - 480 dpi
xxxhdpi - 640 dpi
Note: This method is implemented on Android, Linux (X11), macOS and Windows. Returns 72
on unsupported platforms.
public int ScreenGetDpi(int screen = -1)
Parameters
screen
int
Returns
ScreenGetImage(int)
Returns screenshot of the screen
.
Note: This method is implemented on Linux (X11), macOS, and Windows.
Note: On macOS, this method requires "Screen Recording" permission, if permission is not granted it will return desktop wallpaper color.
public Image ScreenGetImage(int screen = -1)
Parameters
screen
int
Returns
ScreenGetMaxScale()
Returns the greatest scale factor of all screens.
Note: On macOS returned value is 2.0
if there is at least one hiDPI (Retina) screen in the system, and 1.0
in all other cases.
Note: This method is implemented only on macOS.
public float ScreenGetMaxScale()
Returns
ScreenGetOrientation(int)
Returns the screen
's current orientation. See also ScreenSetOrientation(ScreenOrientation, int).
Note: This method is implemented on Android and iOS.
public DisplayServer.ScreenOrientation ScreenGetOrientation(int screen = -1)
Parameters
screen
int
Returns
ScreenGetPixel(Vector2I)
Returns color of the display pixel at the position
.
Note: This method is implemented on Linux (X11), macOS, and Windows.
Note: On macOS, this method requires "Screen Recording" permission, if permission is not granted it will return desktop wallpaper color.
public Color ScreenGetPixel(Vector2I position)
Parameters
position
Vector2I
Returns
ScreenGetPosition(int)
Returns the screen's top-left corner position in pixels. On multi-monitor setups, the screen position is relative to the virtual desktop area. On multi-monitor setups with different screen resolutions or orientations, the origin may be located outside any display like this:
* (0, 0) +-------+
| |
+-------------+ | |
| | | |
| | | |
+-------------+ +-------+
See also ScreenGetSize(int).
public Vector2I ScreenGetPosition(int screen = -1)
Parameters
screen
int
Returns
ScreenGetRefreshRate(int)
Returns the current refresh rate of the specified screen. If screen
is ScreenOfMainWindow (the default value), a screen with the main window will be used.
Note: Returns -1.0
if the DisplayServer fails to find the refresh rate for the specified screen. On Web, ScreenGetRefreshRate(int) will always return -1.0
as there is no way to retrieve the refresh rate on that platform.
To fallback to a default refresh rate if the method fails, try:
var refresh_rate = DisplayServer.screen_get_refresh_rate()
if refresh_rate < 0:
refresh_rate = 60.0
public float ScreenGetRefreshRate(int screen = -1)
Parameters
screen
int
Returns
ScreenGetScale(int)
Returns the scale factor of the specified screen by index.
Note: On macOS returned value is 2.0
for hiDPI (Retina) screen, and 1.0
for all other cases.
Note: This method is implemented only on macOS.
public float ScreenGetScale(int screen = -1)
Parameters
screen
int
Returns
ScreenGetSize(int)
Returns the screen's size in pixels. See also ScreenGetPosition(int) and ScreenGetUsableRect(int).
public Vector2I ScreenGetSize(int screen = -1)
Parameters
screen
int
Returns
ScreenGetUsableRect(int)
Returns the portion of the screen that is not obstructed by a status bar in pixels. See also ScreenGetSize(int).
public Rect2I ScreenGetUsableRect(int screen = -1)
Parameters
screen
int
Returns
ScreenIsKeptOn()
Returns true
if the screen should never be turned off by the operating system's power-saving measures. See also ScreenSetKeepOn(bool).
public bool ScreenIsKeptOn()
Returns
ScreenSetKeepOn(bool)
Sets whether the screen should never be turned off by the operating system's power-saving measures. See also ScreenIsKeptOn().
public void ScreenSetKeepOn(bool enable)
Parameters
enable
bool
ScreenSetOrientation(ScreenOrientation, int)
Sets the screen
's orientation
. See also ScreenGetOrientation(int).
Note: On iOS, this method has no effect if ProjectSettings.display/window/handheld/orientation
is not set to Sensor.
public void ScreenSetOrientation(DisplayServer.ScreenOrientation orientation, int screen = -1)
Parameters
orientation
DisplayServer.ScreenOrientationscreen
int
SetIcon(Image)
Sets the window icon (usually displayed in the top-left corner) with an Image. To use icons in the operating system's native format, use SetNativeIcon(string) instead.
public void SetIcon(Image image)
Parameters
image
Image
SetNativeIcon(string)
Sets the window icon (usually displayed in the top-left corner) in the operating system's native format. The file at fileName
must be in .ico
format on Windows or .icns
on macOS. By using specially crafted .ico
or .icns
icons, SetNativeIcon(string) allows specifying different icons depending on the size the icon is displayed at. This size is determined by the operating system and user preferences (including the display scale factor). To use icons in other formats, use SetIcon(Image) instead.
public void SetNativeIcon(string fileName)
Parameters
fileName
string
TabletGetCurrentDriver()
Returns current active tablet driver name.
Note: This method is implemented only on Windows.
public string TabletGetCurrentDriver()
Returns
TabletGetDriverCount()
Returns the total number of available tablet drivers.
Note: This method is implemented only on Windows.
public int TabletGetDriverCount()
Returns
TabletGetDriverName(int)
Returns the tablet driver name for the given index.
Note: This method is implemented only on Windows.
public string TabletGetDriverName(int idx)
Parameters
idx
int
Returns
TabletSetCurrentDriver(string)
Set active tablet driver name.
Note: This method is implemented only on Windows.
public void TabletSetCurrentDriver(string name)
Parameters
name
string
TtsGetVoices()
Returns an Array of voice information dictionaries.
Each Dictionary contains two string entries:
- name
is voice name.
- id
is voice identifier.
- language
is language code in lang_Variant
format. The lang
part is a 2 or 3-letter code based on the ISO-639 standard, in lowercase. The Variant
part is an engine-dependent string describing country, region or/and dialect.
Note that Godot depends on system libraries for text-to-speech functionality. These libraries are installed by default on Windows and macOS, but not on all Linux distributions. If they are not present, this method will return an empty list. This applies to both Godot users on Linux, as well as end-users on Linux running Godot games that use text-to-speech.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public Array<Dictionary> TtsGetVoices()
Returns
TtsGetVoicesForLanguage(string)
Returns an string[] of voice identifiers for the language
.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public string[] TtsGetVoicesForLanguage(string language)
Parameters
language
string
Returns
- string[]
TtsIsPaused()
Returns true
if the synthesizer is in a paused state.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public bool TtsIsPaused()
Returns
TtsIsSpeaking()
Returns true
if the synthesizer is generating speech, or have utterance waiting in the queue.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public bool TtsIsSpeaking()
Returns
TtsPause()
Puts the synthesizer into a paused state.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public void TtsPause()
TtsResume()
Resumes the synthesizer if it was paused.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public void TtsResume()
TtsSetUtteranceCallback(TtsUtteranceEvent, Callable)
Adds a callback, which is called when the utterance has started, finished, canceled or reached a text boundary.
- Started, Ended, and Canceled callable's method should take one int parameter, the utterance ID.
- Boundary callable's method should take two int parameters, the index of the character and the utterance ID.
Note: The granularity of the boundary callbacks is engine dependent.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public void TtsSetUtteranceCallback(DisplayServer.TtsUtteranceEvent @event, Callable callable)
Parameters
event
DisplayServer.TtsUtteranceEventcallable
Callable
TtsSpeak(string, string, int, float, float, int, bool)
Adds an utterance to the queue. If interrupt
is true
, the queue is cleared first.
- voice
identifier is one of the "id"
values returned by TtsGetVoices() or one of the values returned by TtsGetVoicesForLanguage(string).
- volume
ranges from 0
(lowest) to 100
(highest).
- pitch
ranges from 0.0
(lowest) to 2.0
(highest), 1.0
is default pitch for the current voice.
- rate
ranges from 0.1
(lowest) to 10.0
(highest), 1.0
is a normal speaking rate. Other values act as a percentage relative.
- utteranceId
is passed as a parameter to the callback functions.
Note: On Windows and Linux (X11), utterance text
can use SSML markup. SSML support is engine and voice dependent. If the engine does not support SSML, you should strip out all XML markup before calling TtsSpeak(string, string, int, float, float, int, bool).
Note: The granularity of pitch, rate, and volume is engine and voice dependent. Values may be truncated.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public void TtsSpeak(string text, string voice, int volume = 50, float pitch = 1, float rate = 1, int utteranceId = 0, bool interrupt = false)
Parameters
TtsStop()
Stops synthesis in progress and removes all utterances from the queue.
Note: This method is implemented on Android, iOS, Web, Linux (X11), macOS, and Windows.
Note:
ProjectSettings.audio/general/text_to_speech
should be true
to use text-to-speech.
public void TtsStop()
VirtualKeyboardGetHeight()
Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden.
public int VirtualKeyboardGetHeight()
Returns
VirtualKeyboardHide()
Hides the virtual keyboard if it is shown, does nothing otherwise.
public void VirtualKeyboardHide()
VirtualKeyboardShow(string, Rect2?, VirtualKeyboardType, int, int, int)
Shows the virtual keyboard if the platform has one.
existingText
parameter is useful for implementing your own LineEdit or TextEdit, as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions).
position
parameter is the screen space Rect2 of the edited text.
type
parameter allows configuring which type of virtual keyboard to show.
maxLength
limits the number of characters that can be entered if different from -1
.
cursorStart
can optionally define the current text cursor position if cursorEnd
is not set.
cursorStart
and cursorEnd
can optionally define the current text selection.
Note: This method is implemented on Android, iOS and Web.
public void VirtualKeyboardShow(string existingText, Rect2? position = null, DisplayServer.VirtualKeyboardType type = VirtualKeyboardType.Default, int maxLength = -1, int cursorStart = -1, int cursorEnd = -1)
Parameters
existingText
stringposition
Rect2?If the parameter is null, then the default value is
new Rect2(new Vector2(0, 0), new Vector2(0, 0))
.type
DisplayServer.VirtualKeyboardTypemaxLength
intcursorStart
intcursorEnd
int
WarpMouse(Vector2I)
Sets the mouse cursor position to the given position
relative to an origin at the upper left corner of the currently focused game Window Manager window.
Note: WarpMouse(Vector2I) is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.
public void WarpMouse(Vector2I position)
Parameters
position
Vector2I
WindowCanDraw(int)
Returns true
if anything can be drawn in the window specified by windowId
, false
otherwise. Using the --disable-render-loop
command line argument or a headless build will return false
.
public bool WindowCanDraw(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetActivePopup()
Returns ID of the active popup window, or InvalidWindowId if there is none.
public int WindowGetActivePopup()
Returns
WindowGetAttachedInstanceId(int)
Returns the GetInstanceId() of the Window the windowId
is attached to.
public ulong WindowGetAttachedInstanceId(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetCurrentScreen(int)
Returns the screen the window specified by windowId
is currently positioned on. If the screen overlaps multiple displays, the screen where the window's center is located is returned. See also WindowSetCurrentScreen(int, int).
public int WindowGetCurrentScreen(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetFlag(WindowFlags, int)
Returns the current value of the given window's flag
.
public bool WindowGetFlag(DisplayServer.WindowFlags flag, int windowId = 0)
Parameters
flag
DisplayServer.WindowFlagswindowId
int
Returns
WindowGetMaxSize(int)
Returns the window's maximum size (in pixels). See also WindowSetMaxSize(Vector2I, int).
public Vector2I WindowGetMaxSize(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetMinSize(int)
Returns the window's minimum size (in pixels). See also WindowSetMinSize(Vector2I, int).
public Vector2I WindowGetMinSize(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetMode(int)
Returns the mode of the given window.
public DisplayServer.WindowMode WindowGetMode(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetNativeHandle(HandleType, int)
Returns internal structure pointers for use in plugins.
Note: This method is implemented on Android, Linux (X11), macOS and Windows.
public long WindowGetNativeHandle(DisplayServer.HandleType handleType, int windowId = 0)
Parameters
handleType
DisplayServer.HandleTypewindowId
int
Returns
WindowGetPopupSafeRect(int)
Returns the bounding box of control, or menu item that was used to open the popup window, in the screen coordinate system.
public Rect2I WindowGetPopupSafeRect(int window)
Parameters
window
int
Returns
WindowGetPosition(int)
Returns the position of the client area of the given window on the screen.
public Vector2I WindowGetPosition(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetPositionWithDecorations(int)
Returns the position of the given window on the screen including the borders drawn by the operating system. See also WindowGetPosition(int).
public Vector2I WindowGetPositionWithDecorations(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetSafeTitleMargins(int)
Returns left margins (x
), right margins (y
) and height (z
) of the title that are safe to use (contains no buttons or other elements) when ExtendToTitle flag is set.
public Vector3I WindowGetSafeTitleMargins(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetSize(int)
Returns the size of the window specified by windowId
(in pixels), excluding the borders drawn by the operating system. This is also called the "client area". See also WindowGetSizeWithDecorations(int), WindowSetSize(Vector2I, int) and WindowGetPosition(int).
public Vector2I WindowGetSize(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetSizeWithDecorations(int)
Returns the size of the window specified by windowId
(in pixels), including the borders drawn by the operating system. See also WindowGetSize(int).
public Vector2I WindowGetSizeWithDecorations(int windowId = 0)
Parameters
windowId
int
Returns
WindowGetTitleSize(string, int)
Returns the estimated window title bar size (including text and window buttons) for the window specified by windowId
(in pixels). This method does not change the window title.
Note: This method is implemented on macOS and Windows.
public Vector2I WindowGetTitleSize(string title, int windowId = 0)
Parameters
Returns
WindowGetVsyncMode(int)
Returns the V-Sync mode of the given window.
public DisplayServer.VSyncMode WindowGetVsyncMode(int windowId = 0)
Parameters
windowId
int
Returns
WindowIsFocused(int)
Returns true
if the window specified by windowId
is focused.
public bool WindowIsFocused(int windowId = 0)
Parameters
windowId
int
Returns
WindowIsMaximizeAllowed(int)
Returns true
if the given window can be maximized (the maximize button is enabled).
public bool WindowIsMaximizeAllowed(int windowId = 0)
Parameters
windowId
int
Returns
WindowMaximizeOnTitleDblClick()
Returns true
, if double-click on a window title should maximize it.
Note: This method is implemented only on macOS.
public bool WindowMaximizeOnTitleDblClick()
Returns
WindowMinimizeOnTitleDblClick()
Returns true
, if double-click on a window title should minimize it.
Note: This method is implemented only on macOS.
public bool WindowMinimizeOnTitleDblClick()
Returns
WindowMoveToForeground(int)
Moves the window specified by windowId
to the foreground, so that it is visible over other windows.
public void WindowMoveToForeground(int windowId = 0)
Parameters
windowId
int
WindowRequestAttention(int)
Makes the window specified by windowId
request attention, which is materialized by the window title and taskbar entry blinking until the window is focused. This usually has no visible effect if the window is currently focused. The exact behavior varies depending on the operating system.
public void WindowRequestAttention(int windowId = 0)
Parameters
windowId
int
WindowSetCurrentScreen(int, int)
Moves the window specified by windowId
to the specified screen
. See also WindowGetCurrentScreen(int).
public void WindowSetCurrentScreen(int screen, int windowId = 0)
Parameters
WindowSetDropFilesCallback(Callable, int)
Sets the callback
that should be called when files are dropped from the operating system's file manager to the window specified by windowId
.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
Note: This method is implemented on Windows, macOS, Linux (X11) and Web.
public void WindowSetDropFilesCallback(Callable callback, int windowId = 0)
Parameters
WindowSetExclusive(int, bool)
If set to true
, this window will always stay on top of its parent window, parent window will ignore input while this window is opened.
Note: On macOS, exclusive windows are confined to the same space (virtual desktop or screen) as the parent window.
Note: This method is implemented on macOS and Windows.
public void WindowSetExclusive(int windowId, bool exclusive)
Parameters
WindowSetFlag(WindowFlags, bool, int)
Enables or disables the given window's given flag
. See DisplayServer.WindowFlags for possible values and their behavior.
public void WindowSetFlag(DisplayServer.WindowFlags flag, bool enabled, int windowId = 0)
Parameters
flag
DisplayServer.WindowFlagsenabled
boolwindowId
int
WindowSetImeActive(bool, int)
Sets whether Input Method Editor should be enabled for the window specified by windowId
. See also WindowSetImePosition(Vector2I, int).
public void WindowSetImeActive(bool active, int windowId = 0)
Parameters
WindowSetImePosition(Vector2I, int)
Sets the position of the Input Method Editor popup for the specified windowId
. Only effective if WindowSetImeActive(bool, int) was set to true
for the specified windowId
.
public void WindowSetImePosition(Vector2I position, int windowId = 0)
Parameters
WindowSetInputEventCallback(Callable, int)
Sets the callback
that should be called when any InputEvent is sent to the window specified by windowId
.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
public void WindowSetInputEventCallback(Callable callback, int windowId = 0)
Parameters
WindowSetInputTextCallback(Callable, int)
Sets the callback
that should be called when text is entered using the virtual keyboard to the window specified by windowId
.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
public void WindowSetInputTextCallback(Callable callback, int windowId = 0)
Parameters
WindowSetMaxSize(Vector2I, int)
Sets the maximum size of the window specified by windowId
in pixels. Normally, the user will not be able to drag the window to make it smaller than the specified size. See also WindowGetMaxSize(int).
Note: It's recommended to change this value using MaxSize instead.
Note: Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.
public void WindowSetMaxSize(Vector2I maxSize, int windowId = 0)
Parameters
WindowSetMinSize(Vector2I, int)
Sets the minimum size for the given window to minSize
(in pixels). Normally, the user will not be able to drag the window to make it larger than the specified size. See also WindowGetMinSize(int).
Note: It's recommended to change this value using MinSize instead.
Note: By default, the main window has a minimum size of Vector2i(64, 64)
. This prevents issues that can arise when the window is resized to a near-zero size.
Note: Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.
public void WindowSetMinSize(Vector2I minSize, int windowId = 0)
Parameters
WindowSetMode(WindowMode, int)
Sets window mode for the given window to mode
. See DisplayServer.WindowMode for possible values and how each mode behaves.
Note: Setting the window to full screen forcibly sets the borderless flag to true
, so make sure to set it back to false
when not wanted.
public void WindowSetMode(DisplayServer.WindowMode mode, int windowId = 0)
Parameters
mode
DisplayServer.WindowModewindowId
int
WindowSetMousePassthrough(Vector2[], int)
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.
DisplayServer.WindowSetMousePassthrough(GetNode<Path2D>("Path2D").Curve.GetBakedPoints());
// Set region, using Polygon2D node.
DisplayServer.WindowSetMousePassthrough(GetNode<Polygon2D>("Polygon2D").Polygon);
// Reset region to default.
DisplayServer.WindowSetMousePassthrough(new Vector2[] {});
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 method is implemented on Linux (X11), macOS and Windows.
public void WindowSetMousePassthrough(Vector2[] region, int windowId = 0)
Parameters
WindowSetPopupSafeRect(int, Rect2I)
Sets the bounding box of control, or menu item that was used to open the popup window, in the screen coordinate system. Clicking this area will not auto-close this popup.
public void WindowSetPopupSafeRect(int window, Rect2I rect)
Parameters
WindowSetPosition(Vector2I, int)
Sets the position of the given window to position
. On multi-monitor setups, the screen position is relative to the virtual desktop area. On multi-monitor setups with different screen resolutions or orientations, the origin may be located outside any display like this:
* (0, 0) +-------+
| |
+-------------+ | |
| | | |
| | | |
+-------------+ +-------+
See also WindowGetPosition(int) and WindowSetSize(Vector2I, int).
Note: It's recommended to change this value using Position instead.
public void WindowSetPosition(Vector2I position, int windowId = 0)
Parameters
WindowSetRectChangedCallback(Callable, int)
Sets the callback
that will be called when the window specified by windowId
is moved or resized.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
public void WindowSetRectChangedCallback(Callable callback, int windowId = 0)
Parameters
WindowSetSize(Vector2I, int)
Sets the size of the given window to size
(in pixels). See also WindowGetSize(int) and WindowGetPosition(int).
Note: It's recommended to change this value using Size instead.
public void WindowSetSize(Vector2I size, int windowId = 0)
Parameters
WindowSetTitle(string, int)
Sets the title of the given window to title
.
Note: It's recommended to change this value using Title instead.
Note: Avoid changing the window title every frame, as this can cause performance issues on certain window managers. Try to change the window title only a few times per second at most.
public void WindowSetTitle(string title, int windowId = 0)
Parameters
WindowSetTransient(int, int)
Sets window transient parent. Transient window is 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: It's recommended to change this value using Transient instead.
Note: The behavior might be different depending on the platform.
public void WindowSetTransient(int windowId, int parentWindowId)
Parameters
WindowSetVsyncMode(VSyncMode, int)
Sets the V-Sync mode of the given window. See also ProjectSettings.display/window/vsync/vsync_mode
.
See DisplayServer.VSyncMode for possible values and how they affect the behavior of your application.
Depending on the platform and used renderer, the engine will fall back to Enabled if the desired mode is not supported.
Note: V-Sync modes other than Enabled are only supported in the Forward+ and Mobile rendering methods, not Compatibility.
public void WindowSetVsyncMode(DisplayServer.VSyncMode vsyncMode, int windowId = 0)
Parameters
vsyncMode
DisplayServer.VSyncModewindowId
int
WindowSetWindowButtonsOffset(Vector2I, int)
When ExtendToTitle flag is set, set offset to the center of the first titlebar button.
Note: This flag is implemented only on macOS.
public void WindowSetWindowButtonsOffset(Vector2I offset, int windowId = 0)
Parameters
WindowSetWindowEventCallback(Callable, int)
Sets the callback
that will be called when an event occurs in the window specified by windowId
.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
public void WindowSetWindowEventCallback(Callable callback, int windowId = 0)