Table of Contents

Class DisplayServer

A server interface for low-level window management.

Inheritance
DisplayServer

Remarks

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.

Fields

SCREEN_WITH_MOUSE_FOCUS

Represents the screen containing the mouse pointer.

Note: On Linux (Wayland), this constant always represents the screen at index 0.

const SCREEN_WITH_MOUSE_FOCUS = -4

SCREEN_WITH_KEYBOARD_FOCUS

Represents the screen containing the window with the keyboard focus.

Note: On Linux (Wayland), this constant always represents the screen at index 0.

const SCREEN_WITH_KEYBOARD_FOCUS = -3

SCREEN_PRIMARY

Represents the primary screen.

Note: On Linux (Wayland), this constant always represents the screen at index 0.

const SCREEN_PRIMARY = -2

SCREEN_OF_MAIN_WINDOW

Represents the screen where the main window is located. This is usually the default value in functions that allow specifying one of several screens.

Note: On Linux (Wayland), this constant always represents the screen at index 0.

const SCREEN_OF_MAIN_WINDOW = -1

MAIN_WINDOW_ID

The ID of the main window spawned by the engine, which can be passed to methods expecting a window_id.

const MAIN_WINDOW_ID = 0

INVALID_WINDOW_ID

The ID that refers to a nonexistent window. This is returned by some DisplayServer methods if no window matches the requested result.

const INVALID_WINDOW_ID = -1

INVALID_INDICATOR_ID

The ID that refers to a nonexistent application status indicator.

const INVALID_INDICATOR_ID = -1

Methods

beep

Qualifiers: const

Plays the beep sound from the operative system, if possible. Because it comes from the OS, the beep sound will be audible even if the application is muted. It may also be disabled for the entire OS by the user.

Note: This method is implemented on macOS, Linux (X11/Wayland), and Windows.

void beep

clipboard_get

Qualifiers: const

Returns the user's clipboard as a string if possible.

String clipboard_get

clipboard_get_image

Qualifiers: const

Returns the user's clipboard as an image if possible.

Note: This method uses the copied pixel data, e.g. from a image editing software or a web browser, not an image file copied from file explorer.

Image clipboard_get_image

clipboard_get_primary

Qualifiers: const

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/Wayland).

String clipboard_get_primary

clipboard_has

Qualifiers: const

Returns true if there is a text content on the user's clipboard.

bool clipboard_has

clipboard_has_image

Qualifiers: const

Returns true if there is an image content on the user's clipboard.

bool clipboard_has_image

clipboard_set(String)

Sets the user's clipboard content to the given string.

void clipboard_set(String clipboard)

Parameters

clipboard String

clipboard_set_primary(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/Wayland).

void clipboard_set_primary(String clipboard_primary)

Parameters

clipboard_primary String

create_status_indicator(Texture2D, String, Callable)

Creates a new application status indicator with the specified icon, tooltip, and activation callback.

callback should take two arguments: the pressed mouse button (one of the MouseButton constants) and the click position in screen coordinates (a Vector2i).

int create_status_indicator(Texture2D icon, String tooltip, Callable callback)

Parameters

icon Texture2D
tooltip String
callback Callable

cursor_get_shape

Qualifiers: const

Returns the default mouse cursor shape set by DisplayServer.cursor_set_shape.

int cursor_get_shape

cursor_set_custom_image(Resource, int, Vector2)

Sets a custom mouse cursor image for the given shape. This means the user's operating system and mouse cursor theme will no longer influence the mouse cursor's appearance.

cursor can be either a Texture2D or an Image, and it should not be larger than 256×256 to display correctly. Optionally, hotspot can be set to offset the image's position relative to the click point. By default, hotspot is set to the top-left corner of the image. See also DisplayServer.cursor_set_shape.

void cursor_set_custom_image(Resource cursor, int shape, Vector2 hotspot)

Parameters

cursor Resource
shape int
hotspot Vector2

cursor_set_shape(int)

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 cursor_get_shape and DisplayServer.cursor_set_custom_image.

void cursor_set_shape(int shape)

Parameters

shape int

delete_status_indicator(int)

Removes the application status indicator.

void delete_status_indicator(int id)

Parameters

id int

dialog_input_text(String, String, String, Callable)

Shows a text input dialog which uses the operating system's native look-and-feel. callback should accept a single String parameter which contains the text field's contents.

Note: This method is implemented if the display server has the DisplayServer.FEATURE_NATIVE_DIALOG_INPUT feature. Supported platforms include macOS, Windows, and Android.

int dialog_input_text(String title, String description, String existing_text, Callable callback)

Parameters

title String
description String
existing_text String
callback Callable

dialog_show(String, String, PackedStringArray, Callable)

Shows a text dialog which uses the operating system's native look-and-feel. callback should accept a single int parameter which corresponds to the index of the pressed button.

Note: This method is implemented if the display server has the DisplayServer.FEATURE_NATIVE_DIALOG feature. Supported platforms include macOS, Windows, and Android.

int dialog_show(String title, String description, PackedStringArray buttons, Callable callback)

Parameters

title String
description String
buttons PackedStringArray
callback Callable

enable_for_stealing_focus(int)

Allows the process_id 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.

void enable_for_stealing_focus(int process_id)

Parameters

process_id int

file_dialog_show(String, String, String, bool, int, PackedStringArray, Callable)

Displays OS native dialog for selecting files or directories in the file system.

Each filter string in the filters array should be formatted like this: *.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg. The description text of the filter is optional and can be omitted. It is recommended to set both file extension and MIME type. See also filters.

Callbacks have the following arguments: status: bool, selected_paths: PackedStringArray, selected_filter_index: int. On Android, callback argument selected_filter_index is always zero.

Note: This method is implemented if the display server has the DisplayServer.FEATURE_NATIVE_DIALOG_FILE feature. Supported platforms include Linux (X11/Wayland), Windows, macOS, and Android.

Note: current_directory might be ignored.

Note: Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types.

Note: On Android and Linux, show_hidden is ignored.

Note: On Android and 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 get_granted_permissions to get a list of saved bookmarks.

int file_dialog_show(String title, String current_directory, String filename, bool show_hidden, int mode, PackedStringArray filters, Callable callback)

Parameters

title String
current_directory String
filename String
show_hidden bool
mode int
filters PackedStringArray
callback Callable

file_dialog_with_options_show(String, String, String, String, bool, int, PackedStringArray, Dictionary[], Callable)

Displays OS native dialog for selecting files or directories in the file system with additional user selectable options.

Each filter string in the filters array should be formatted like this: *.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg. The description text of the filter is optional and can be omitted. It is recommended to set both file extension and MIME type. See also filters.

options is array of Dictionarys with the following keys:

  • "name" - option's name String.

  • "values" - PackedStringArray of values. If empty, boolean option (check box) is used.

  • "default" - default selected option index (int) or default boolean value (bool).

Callbacks have the following arguments: status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary.

Note: This method is implemented if the display server has the DisplayServer.FEATURE_NATIVE_DIALOG_FILE_EXTRA feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.

Note: current_directory might be ignored.

Note: Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types.

Note: On Linux (X11), show_hidden 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 get_granted_permissions to get a list of saved bookmarks.

int file_dialog_with_options_show(String title, String current_directory, String root, String filename, bool show_hidden, int mode, PackedStringArray filters, Dictionary[] options, Callable callback)

Parameters

title String
current_directory String
root String
filename String
show_hidden bool
mode int
filters PackedStringArray
options Dictionary[]
callback Callable

force_process_and_drop_events

Forces window manager processing while ignoring all InputEvents. See also process_events.

Note: This method is implemented on Windows and macOS.

void force_process_and_drop_events

get_accent_color

Qualifiers: const

Returns OS theme accent color. Returns Color(0, 0, 0, 0), if accent color is unknown.

Note: This method is implemented on macOS, Windows, and Android.

Color get_accent_color

get_base_color

Qualifiers: const

Returns the OS theme base color (default control background). Returns Color(0, 0, 0, 0) if the base color is unknown.

Note: This method is implemented on macOS, Windows, and Android.

Color get_base_color

get_display_cutouts

Qualifiers: const

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

Note: Currently only implemented on Android. Other platforms will return an empty array even if they do have display cutouts or notches.

Rect2[] get_display_cutouts

get_display_safe_area

Qualifiers: const

Returns the unobscured area of the display where interactive controls should be rendered. See also get_display_cutouts.

Note: Currently only implemented on Android and iOS. On other platforms, screen_get_usable_rect(SCREEN_OF_MAIN_WINDOW) will be returned as a fallback. See also DisplayServer.screen_get_usable_rect.

Rect2i get_display_safe_area

get_keyboard_focus_screen

Qualifiers: const

Returns the index of the screen containing the window with the keyboard focus, or the primary screen if there's no focused window.

int get_keyboard_focus_screen

get_name

Qualifiers: const

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 (currently X11 and Wayland).

The names of built-in display servers are Windows, macOS, X11 (Linux), Wayland (Linux), Android, iOS, web (HTML5), and headless (when started with the --headless command line argument).

String get_name

get_primary_screen

Qualifiers: const

Returns index of the primary screen.

int get_primary_screen

get_screen_count

Qualifiers: const

Returns the number of displays available.

int get_screen_count

get_screen_from_rect(Rect2)

Qualifiers: const

Returns the index of the screen that overlaps the most with the given rectangle. Returns -1 if the rectangle doesn't overlap with any screen or has no area.

int get_screen_from_rect(Rect2 rect)

Parameters

rect Rect2

get_swap_cancel_ok

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 gui/common/swap_cancel_ok.

Note: This doesn't affect native dialogs such as the ones spawned by DisplayServer.dialog_show.

bool get_swap_cancel_ok

get_window_at_screen_position(Vector2i)

Qualifiers: const

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)        +-------+
                |       |
+-------------+ |       |
|             | |       |
|             | |       |
+-------------+ +-------+

int get_window_at_screen_position(Vector2i position)

Parameters

position Vector2i

get_window_list

Qualifiers: const

Returns the list of Godot window IDs belonging to this process.

Note: Native dialogs are not included in this list.

PackedInt32Array get_window_list

global_menu_add_check_item(String, String, Callable, Callable, Variant, int, int)

Adds a new checkable item with text label to the global menu with ID menu_root.

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 key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_check_item(String menu_root, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_icon_check_item(String, Texture2D, String, Callable, Callable, Variant, int, int)

Adds a new checkable item with text label and icon icon to the global menu with ID menu_root.

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 key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_icon_check_item(String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
icon Texture2D
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_icon_item(String, Texture2D, String, Callable, Callable, Variant, int, int)

Adds a new item with text label and icon icon to the global menu with ID menu_root.

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 key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_icon_item(String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
icon Texture2D
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_icon_radio_check_item(String, Texture2D, String, Callable, Callable, Variant, int, int)

Adds a new radio-checkable item with text label and icon icon to the global menu with ID menu_root.

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 DisplayServer.global_menu_set_item_checked for more info on how to control it.

Note: The callback and key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_icon_radio_check_item(String menu_root, Texture2D icon, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
icon Texture2D
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_item(String, String, Callable, Callable, Variant, int, int)

Adds a new item with text label to the global menu with ID menu_root.

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 key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_item(String menu_root, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_multistate_item(String, String, int, int, Callable, Callable, Variant, int, int)

Adds a new item with text label to the global menu with ID menu_root.

Contrarily to normal binary items, multistate items can have more than two states, as defined by max_states. Each press or activate of the item will increase the state by one. The default value is defined by default_state.

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 key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_multistate_item(String menu_root, String label, int max_states, int default_state, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
label String
max_states int
default_state int
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_radio_check_item(String, String, Callable, Callable, Variant, int, int)

Adds a new radio-checkable item with text label to the global menu with ID menu_root.

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 DisplayServer.global_menu_set_item_checked for more info on how to control it.

Note: The callback and key_callback 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_radio_check_item(String menu_root, String label, Callable callback, Callable key_callback, Variant tag, int accelerator, int index)

Parameters

menu_root String
label String
callback Callable
key_callback Callable
tag Variant
accelerator int
index int

global_menu_add_separator(String, int)

Adds a separator between items to the global menu with ID menu_root. 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_separator(String menu_root, int index)

Parameters

menu_root String
index int

global_menu_add_submenu_item(String, String, String, int)

Adds an item that will act as a submenu of the global menu menu_root. 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).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

int global_menu_add_submenu_item(String menu_root, String label, String submenu, int index)

Parameters

menu_root String
label String
submenu String
index int

global_menu_clear(String)

Removes all items from the global menu with ID menu_root.

Note: This method is implemented only on macOS.

Supported system menu IDs:

"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).

void global_menu_clear(String menu_root)

Parameters

menu_root String

global_menu_get_item_accelerator(String, int)

Qualifiers: const

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.

int global_menu_get_item_accelerator(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_callback(String, int)

Qualifiers: const

Returns the callback of the item at index idx.

Note: This method is implemented only on macOS.

Callable global_menu_get_item_callback(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_count(String)

Qualifiers: const

Returns number of items in the global menu with ID menu_root.

Note: This method is implemented only on macOS.

int global_menu_get_item_count(String menu_root)

Parameters

menu_root String

global_menu_get_item_icon(String, int)

Qualifiers: const

Returns the icon of the item at index idx.

Note: This method is implemented only on macOS.

Texture2D global_menu_get_item_icon(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_indentation_level(String, int)

Qualifiers: const

Returns the horizontal offset of the item at the given idx.

Note: This method is implemented only on macOS.

int global_menu_get_item_indentation_level(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_index_from_tag(String, Variant)

Qualifiers: const

Returns the index of the item with the specified tag. Indices are automatically assigned to each item by the engine, and cannot be set manually.

Note: This method is implemented only on macOS.

int global_menu_get_item_index_from_tag(String menu_root, Variant tag)

Parameters

menu_root String
tag Variant

global_menu_get_item_index_from_text(String, String)

Qualifiers: const

Returns the index of the item with the specified text. Indices are automatically assigned to each item by the engine, and cannot be set manually.

Note: This method is implemented only on macOS.

int global_menu_get_item_index_from_text(String menu_root, String text)

Parameters

menu_root String
text String

global_menu_get_item_key_callback(String, int)

Qualifiers: const

Returns the callback of the item accelerator at index idx.

Note: This method is implemented only on macOS.

Callable global_menu_get_item_key_callback(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_max_states(String, int)

Qualifiers: const

Returns number of states of a multistate item. See DisplayServer.global_menu_add_multistate_item for details.

Note: This method is implemented only on macOS.

int global_menu_get_item_max_states(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_state(String, int)

Qualifiers: const

Returns the state of a multistate item. See DisplayServer.global_menu_add_multistate_item for details.

Note: This method is implemented only on macOS.

int global_menu_get_item_state(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_submenu(String, int)

Qualifiers: const

Returns the submenu ID of the item at index idx. See DisplayServer.global_menu_add_submenu_item for more info on how to add a submenu.

Note: This method is implemented only on macOS.

String global_menu_get_item_submenu(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_tag(String, int)

Qualifiers: const

Returns the metadata of the specified item, which might be of any type. You can set it with DisplayServer.global_menu_set_item_tag, which provides a simple way of assigning context data to items.

Note: This method is implemented only on macOS.

Variant global_menu_get_item_tag(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_text(String, int)

Qualifiers: const

Returns the text of the item at index idx.

Note: This method is implemented only on macOS.

String global_menu_get_item_text(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_item_tooltip(String, int)

Qualifiers: const

Returns the tooltip associated with the specified index idx.

Note: This method is implemented only on macOS.

String global_menu_get_item_tooltip(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_get_system_menu_roots

Qualifiers: const

Returns Dictionary of supported system menu IDs and names.

Note: This method is implemented only on macOS.

Dictionary global_menu_get_system_menu_roots

global_menu_is_item_checkable(String, int)

Qualifiers: const

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.

bool global_menu_is_item_checkable(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_is_item_checked(String, int)

Qualifiers: const

Returns true if the item at index idx is checked.

Note: This method is implemented only on macOS.

bool global_menu_is_item_checked(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_is_item_disabled(String, int)

Qualifiers: const

Returns true if the item at index idx is disabled. When it is disabled it can't be selected, or its action invoked.

See DisplayServer.global_menu_set_item_disabled for more info on how to disable an item.

Note: This method is implemented only on macOS.

bool global_menu_is_item_disabled(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_is_item_hidden(String, int)

Qualifiers: const

Returns true if the item at index idx is hidden.

See DisplayServer.global_menu_set_item_hidden for more info on how to hide an item.

Note: This method is implemented only on macOS.

bool global_menu_is_item_hidden(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_is_item_radio_checkable(String, int)

Qualifiers: const

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.

bool global_menu_is_item_radio_checkable(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_remove_item(String, int)

Removes the item at index idx from the global menu menu_root.

Note: The indices of items after the removed item will be shifted by one.

Note: This method is implemented only on macOS.

void global_menu_remove_item(String menu_root, int idx)

Parameters

menu_root String
idx int

global_menu_set_item_accelerator(String, int, int)

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.

void global_menu_set_item_accelerator(String menu_root, int idx, int keycode)

Parameters

menu_root String
idx int
keycode int

global_menu_set_item_callback(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.

void global_menu_set_item_callback(String menu_root, int idx, Callable callback)

Parameters

menu_root String
idx int
callback Callable

global_menu_set_item_checkable(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.

void global_menu_set_item_checkable(String menu_root, int idx, bool checkable)

Parameters

menu_root String
idx int
checkable bool

global_menu_set_item_checked(String, int, bool)

Sets the checkstate status of the item at index idx.

Note: This method is implemented only on macOS.

void global_menu_set_item_checked(String menu_root, int idx, bool checked)

Parameters

menu_root String
idx int
checked bool

global_menu_set_item_disabled(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.

void global_menu_set_item_disabled(String menu_root, int idx, bool disabled)

Parameters

menu_root String
idx int
disabled bool

global_menu_set_item_hidden(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.

void global_menu_set_item_hidden(String menu_root, int idx, bool hidden)

Parameters

menu_root String
idx int
hidden bool

global_menu_set_item_hover_callbacks(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.

void global_menu_set_item_hover_callbacks(String menu_root, int idx, Callable callback)

Parameters

menu_root String
idx int
callback Callable

global_menu_set_item_icon(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.

void global_menu_set_item_icon(String menu_root, int idx, Texture2D icon)

Parameters

menu_root String
idx int
icon Texture2D

global_menu_set_item_indentation_level(String, int, int)

Sets the horizontal offset of the item at the given idx.

Note: This method is implemented only on macOS.

void global_menu_set_item_indentation_level(String menu_root, int idx, int level)

Parameters

menu_root String
idx int
level int

global_menu_set_item_key_callback(String, int, Callable)

Sets the callback of the item at index idx. Callback is emitted when its accelerator is activated.

Note: The key_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.

void global_menu_set_item_key_callback(String menu_root, int idx, Callable key_callback)

Parameters

menu_root String
idx int
key_callback Callable

global_menu_set_item_max_states(String, int, int)

Sets number of state of a multistate item. See DisplayServer.global_menu_add_multistate_item for details.

Note: This method is implemented only on macOS.

void global_menu_set_item_max_states(String menu_root, int idx, int max_states)

Parameters

menu_root String
idx int
max_states int

global_menu_set_item_radio_checkable(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.

void global_menu_set_item_radio_checkable(String menu_root, int idx, bool checkable)

Parameters

menu_root String
idx int
checkable bool

global_menu_set_item_state(String, int, int)

Sets the state of a multistate item. See DisplayServer.global_menu_add_multistate_item for details.

Note: This method is implemented only on macOS.

void global_menu_set_item_state(String menu_root, int idx, int state)

Parameters

menu_root String
idx int
state int

global_menu_set_item_submenu(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.

void global_menu_set_item_submenu(String menu_root, int idx, String submenu)

Parameters

menu_root String
idx int
submenu String

global_menu_set_item_tag(String, int, Variant)

Sets the metadata of an item, which may be of any type. You can later get it with DisplayServer.global_menu_get_item_tag, which provides a simple way of assigning context data to items.

Note: This method is implemented only on macOS.

void global_menu_set_item_tag(String menu_root, int idx, Variant tag)

Parameters

menu_root String
idx int
tag Variant

global_menu_set_item_text(String, int, String)

Sets the text of the item at index idx.

Note: This method is implemented only on macOS.

void global_menu_set_item_text(String menu_root, int idx, String text)

Parameters

menu_root String
idx int
text String

global_menu_set_item_tooltip(String, int, String)

Sets the String tooltip of the item at the specified index idx.

Note: This method is implemented only on macOS.

void global_menu_set_item_tooltip(String menu_root, int idx, String tooltip)

Parameters

menu_root String
idx int
tooltip String

global_menu_set_popup_callbacks(String, Callable, Callable)

Registers callables to emit when the menu is respectively about to show or closed. Callback methods should have zero arguments.

void global_menu_set_popup_callbacks(String menu_root, Callable open_callback, Callable close_callback)

Parameters

menu_root String
open_callback Callable
close_callback Callable

has_additional_outputs

Qualifiers: const

Returns true if any additional outputs have been registered via DisplayServer.register_additional_output.

bool has_additional_outputs

has_feature(int)

Qualifiers: const

Returns true if the specified feature is supported by the current DisplayServer, false otherwise.

bool has_feature(int feature)

Parameters

feature int

has_hardware_keyboard

Qualifiers: const

Returns true if hardware keyboard is connected.

Note: This method is implemented on Android and iOS, on other platforms this method always returns true.

bool has_hardware_keyboard

help_set_search_callbacks(Callable, Callable)

Sets native help system search callbacks.

search_callback has the following arguments: String search_string, int result_limit and return a Dictionary with "key, display name" pairs for the search results. Called when the user enters search terms in the Help menu.

action_callback has the following arguments: String key. Called when the user selects a search result in the Help menu.

Note: This method is implemented only on macOS.

void help_set_search_callbacks(Callable search_callback, Callable action_callback)

Parameters

search_callback Callable
action_callback Callable

ime_get_selection

Qualifiers: const

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.

Vector2i ime_get_selection

ime_get_text

Qualifiers: const

Returns the composition string contained within the Input Method Editor window.

Note: This method is implemented only on macOS.

String ime_get_text

is_dark_mode

Qualifiers: const

Returns true if OS is using dark mode.

Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11/Wayland).

bool is_dark_mode

is_dark_mode_supported

Qualifiers: const

Returns true if OS supports dark mode.

Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11/Wayland).

bool is_dark_mode_supported

is_touchscreen_available

Qualifiers: const

Returns true if touch events are available (Android or iOS), the capability is detected on the Web platform or if input_devices/pointing/emulate_touch_from_mouse is true.

bool is_touchscreen_available

is_window_transparency_available

Qualifiers: const

Returns true if the window background can be made transparent. This method returns false if display/window/per_pixel_transparency/allowed is set to false, or if transparency is not supported by the renderer or OS compositor.

bool is_window_transparency_available

keyboard_get_current_layout

Qualifiers: const

Returns active keyboard layout index.

Note: This method is implemented on Linux (X11/Wayland), macOS, and Windows.

int keyboard_get_current_layout

keyboard_get_keycode_from_physical(int)

Qualifiers: const

Converts a physical (US QWERTY) keycode to one in the active keyboard layout.

Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.

int keyboard_get_keycode_from_physical(int keycode)

Parameters

keycode int

keyboard_get_label_from_physical(int)

Qualifiers: const

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/Wayland), macOS and Windows.

int keyboard_get_label_from_physical(int keycode)

Parameters

keycode int

keyboard_get_layout_count

Qualifiers: const

Returns the number of keyboard layouts.

Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.

int keyboard_get_layout_count

keyboard_get_layout_language(int)

Qualifiers: const

Returns the ISO-639/BCP-47 language code of the keyboard layout at position index.

Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.

String keyboard_get_layout_language(int index)

Parameters

index int

keyboard_get_layout_name(int)

Qualifiers: const

Returns the localized name of the keyboard layout at position index.

Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.

String keyboard_get_layout_name(int index)

Parameters

index int

keyboard_set_current_layout(int)

Sets the active keyboard layout.

Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.

void keyboard_set_current_layout(int index)

Parameters

index int

mouse_get_button_state

Qualifiers: const

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

int mouse_get_button_state

mouse_get_mode

Qualifiers: const

Returns the current mouse mode. See also DisplayServer.mouse_set_mode.

int mouse_get_mode

mouse_get_position

Qualifiers: const

Returns the mouse cursor's current position in screen coordinates.

Vector2i mouse_get_position

mouse_set_mode(int)

Sets the current mouse mode. See also mouse_get_mode.

void mouse_set_mode(int mouse_mode)

Parameters

mouse_mode int

process_events

Perform window manager processing, including input flushing. See also force_process_and_drop_events, flush_buffered_events and use_accumulated_input.

void process_events

register_additional_output(Object)

Registers an Object which represents an additional output that will be rendered too, beyond normal windows. The Object is only used as an identifier, which can be later passed to DisplayServer.unregister_additional_output.

This can be used to prevent Godot from skipping rendering when no normal windows are visible.

void register_additional_output(Object object)

Parameters

object Object

screen_get_dpi(int)

Qualifiers: const

Returns the dots per inch density of the specified screen. If screen is SCREEN_OF_MAIN_WINDOW (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/Wayland), macOS and Windows. Returns 72 on unsupported platforms.

int screen_get_dpi(int screen)

Parameters

screen int

screen_get_image(int)

Qualifiers: const

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.

Image screen_get_image(int screen)

Parameters

screen int

screen_get_image_rect(Rect2i)

Qualifiers: const

Returns screenshot of the screen rect.

Note: This method is implemented on macOS and Windows.

Note: On macOS, this method requires "Screen Recording" permission, if permission is not granted it will return desktop wallpaper color.

Image screen_get_image_rect(Rect2i rect)

Parameters

rect Rect2i

screen_get_max_scale

Qualifiers: const

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.

float screen_get_max_scale

screen_get_orientation(int)

Qualifiers: const

Returns the screen's current orientation. See also DisplayServer.screen_set_orientation.

Note: This method is implemented on Android and iOS.

int screen_get_orientation(int screen)

Parameters

screen int

screen_get_pixel(Vector2i)

Qualifiers: const

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.

Color screen_get_pixel(Vector2i position)

Parameters

position Vector2i

screen_get_position(int)

Qualifiers: const

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 DisplayServer.screen_get_size.

Note: On Linux (Wayland) this method always returns (0, 0).

Vector2i screen_get_position(int screen)

Parameters

screen int

screen_get_refresh_rate(int)

Qualifiers: const

Returns the current refresh rate of the specified screen. If screen is SCREEN_OF_MAIN_WINDOW (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, DisplayServer.screen_get_refresh_rate 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

float screen_get_refresh_rate(int screen)

Parameters

screen int

screen_get_scale(int)

Qualifiers: const

Returns the scale factor of the specified screen by index.

Note: On macOS, the returned value is 2.0 for hiDPI (Retina) screens, and 1.0 for all other cases.

Note: On Linux (Wayland), the returned value is accurate only when screen is SCREEN_OF_MAIN_WINDOW. Due to API limitations, passing a direct index will return a rounded-up integer, if the screen has a fractional scale (e.g. 1.25 would get rounded up to 2.0).

Note: This method is implemented on Android, iOS, Web, macOS, and Linux (Wayland).

float screen_get_scale(int screen)

Parameters

screen int

screen_get_size(int)

Qualifiers: const

Returns the screen's size in pixels. See also DisplayServer.screen_get_position and DisplayServer.screen_get_usable_rect.

Vector2i screen_get_size(int screen)

Parameters

screen int

screen_get_usable_rect(int)

Qualifiers: const

Returns the portion of the screen that is not obstructed by a status bar in pixels. See also DisplayServer.screen_get_size.

Rect2i screen_get_usable_rect(int screen)

Parameters

screen int

screen_is_kept_on

Qualifiers: const

Returns true if the screen should never be turned off by the operating system's power-saving measures. See also DisplayServer.screen_set_keep_on.

bool screen_is_kept_on

screen_set_keep_on(bool)

Sets whether the screen should never be turned off by the operating system's power-saving measures. See also screen_is_kept_on.

void screen_set_keep_on(bool enable)

Parameters

enable bool

screen_set_orientation(int, int)

Sets the screen's orientation. See also DisplayServer.screen_get_orientation.

Note: On iOS, this method has no effect if display/window/handheld/orientation is not set to DisplayServer.SCREEN_SENSOR.

void screen_set_orientation(int orientation, int screen)

Parameters

orientation int
screen int

set_icon(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 DisplayServer.set_native_icon instead.

Note: Requires support for DisplayServer.FEATURE_ICON.

void set_icon(Image image)

Parameters

image Image

set_native_icon(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, DisplayServer.set_native_icon 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 DisplayServer.set_icon instead.

Note: Requires support for DisplayServer.FEATURE_NATIVE_ICON.

void set_native_icon(String filename)

Parameters

filename String

set_system_theme_change_callback(Callable)

Sets the callable that should be called when system theme settings are changed. Callback method should have zero arguments.

Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11/Wayland).

void set_system_theme_change_callback(Callable callable)

Parameters

callable Callable

show_emoji_and_symbol_picker

Qualifiers: const

Opens system emoji and symbol picker.

Note: This method is implemented on macOS and Windows.

void show_emoji_and_symbol_picker

status_indicator_get_rect(int)

Qualifiers: const

Returns the rectangle for the given status indicator id in screen coordinates. If the status indicator is not visible, returns an empty Rect2.

Note: This method is implemented on macOS and Windows.

Rect2 status_indicator_get_rect(int id)

Parameters

id int

status_indicator_set_callback(int, Callable)

Sets the application status indicator activation callback. callback should take two arguments: int mouse button index (one of MouseButton values) and Vector2i click position in screen coordinates.

Note: This method is implemented on macOS and Windows.

void status_indicator_set_callback(int id, Callable callback)

Parameters

id int
callback Callable

status_indicator_set_icon(int, Texture2D)

Sets the application status indicator icon.

Note: This method is implemented on macOS and Windows.

void status_indicator_set_icon(int id, Texture2D icon)

Parameters

id int
icon Texture2D

status_indicator_set_menu(int, RID)

Sets the application status indicator native popup menu.

Note: On macOS, the menu is activated by any mouse button. Its activation callback is not triggered.

Note: On Windows, the menu is activated by the right mouse button, selecting the status icon and pressing Shift + F10, or the applications key. The menu's activation callback for the other mouse buttons is still triggered.

Note: Native popup is only supported if NativeMenu supports the NativeMenu.FEATURE_POPUP_MENU feature.

void status_indicator_set_menu(int id, RID menu_rid)

Parameters

id int
menu_rid RID

status_indicator_set_tooltip(int, String)

Sets the application status indicator tooltip.

Note: This method is implemented on macOS and Windows.

void status_indicator_set_tooltip(int id, String tooltip)

Parameters

id int
tooltip String

tablet_get_current_driver

Qualifiers: const

Returns current active tablet driver name.

Note: This method is implemented only on Windows.

String tablet_get_current_driver

tablet_get_driver_count

Qualifiers: const

Returns the total number of available tablet drivers.

Note: This method is implemented only on Windows.

int tablet_get_driver_count

tablet_get_driver_name(int)

Qualifiers: const

Returns the tablet driver name for the given index.

Note: This method is implemented only on Windows.

String tablet_get_driver_name(int idx)

Parameters

idx int

tablet_set_current_driver(String)

Set active tablet driver name.

Supported drivers:

  • winink: Windows Ink API, default (Windows 8.1+ required).

  • wintab: Wacom Wintab API (compatible device driver required).

  • dummy: Dummy driver, tablet input is disabled.

Note: This method is implemented only on Windows.

void tablet_set_current_driver(String name)

Parameters

name String

tts_get_voices

Qualifiers: const

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/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

Dictionary[] tts_get_voices

tts_get_voices_for_language(String)

Qualifiers: const

Returns an PackedStringArray of voice identifiers for the language.

Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

PackedStringArray tts_get_voices_for_language(String language)

Parameters

language String

tts_is_paused

Qualifiers: const

Returns true if the synthesizer is in a paused state.

Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

bool tts_is_paused

tts_is_speaking

Qualifiers: const

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/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

bool tts_is_speaking

tts_pause

Puts the synthesizer into a paused state.

Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

void tts_pause

tts_resume

Resumes the synthesizer if it was paused.

Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

void tts_resume

tts_set_utterance_callback(int, Callable)

Adds a callback, which is called when the utterance has started, finished, canceled or reached a text boundary.

  • DisplayServer.TTS_UTTERANCE_STARTED, DisplayServer.TTS_UTTERANCE_ENDED, and DisplayServer.TTS_UTTERANCE_CANCELED callable's method should take one int parameter, the utterance ID.

  • DisplayServer.TTS_UTTERANCE_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/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

void tts_set_utterance_callback(int event, Callable callable)

Parameters

event int
callable Callable

tts_speak(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 tts_get_voices or one of the values returned by DisplayServer.tts_get_voices_for_language.

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

  • utterance_id is passed as a parameter to the callback functions.

Note: On Windows and Linux (X11/Wayland), 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 DisplayServer.tts_speak.

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/Wayland), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

void tts_speak(String text, String voice, int volume, float pitch, float rate, int utterance_id, bool interrupt)

Parameters

text String
voice String
volume int
pitch float
rate float
utterance_id int
interrupt bool

tts_stop

Stops synthesis in progress and removes all utterances from the queue.

Note: This method is implemented on Android, iOS, Web, Linux (X11/Linux), macOS, and Windows.

Note: audio/general/text_to_speech should be true to use text-to-speech.

void tts_stop

unregister_additional_output(Object)

Unregisters an Object representing an additional output, that was registered via DisplayServer.register_additional_output.

void unregister_additional_output(Object object)

Parameters

object Object

virtual_keyboard_get_height

Qualifiers: const

Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden.

int virtual_keyboard_get_height

virtual_keyboard_hide

Hides the virtual keyboard if it is shown, does nothing otherwise.

void virtual_keyboard_hide

virtual_keyboard_show(String, Rect2, int, int, int, int)

Shows the virtual keyboard if the platform has one.

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

max_length limits the number of characters that can be entered if different from -1.

cursor_start can optionally define the current text cursor position if cursor_end is not set.

cursor_start and cursor_end can optionally define the current text selection.

Note: This method is implemented on Android, iOS and Web.

void virtual_keyboard_show(String existing_text, Rect2 position, int type, int max_length, int cursor_start, int cursor_end)

Parameters

existing_text String
position Rect2
type int
max_length int
cursor_start int
cursor_end int

warp_mouse(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: DisplayServer.warp_mouse is only supported on Windows, macOS, and Linux (X11/Wayland). It has no effect on Android, iOS, and Web.

void warp_mouse(Vector2i position)

Parameters

position Vector2i

window_can_draw(int)

Qualifiers: const

Returns true if anything can be drawn in the window specified by window_id, false otherwise. Using the --disable-render-loop command line argument or a headless build will return false.

bool window_can_draw(int window_id)

Parameters

window_id int

window_get_active_popup

Qualifiers: const

Returns ID of the active popup window, or INVALID_WINDOW_ID if there is none.

int window_get_active_popup

window_get_attached_instance_id(int)

Qualifiers: const

Returns the get_instance_id of the Window the window_id is attached to.

int window_get_attached_instance_id(int window_id)

Parameters

window_id int

window_get_current_screen(int)

Qualifiers: const

Returns the screen the window specified by window_id is currently positioned on. If the screen overlaps multiple displays, the screen where the window's center is located is returned. See also DisplayServer.window_set_current_screen.

int window_get_current_screen(int window_id)

Parameters

window_id int

window_get_flag(int, int)

Qualifiers: const

Returns the current value of the given window's flag.

bool window_get_flag(int flag, int window_id)

Parameters

flag int
window_id int

window_get_max_size(int)

Qualifiers: const

Returns the window's maximum size (in pixels). See also DisplayServer.window_set_max_size.

Vector2i window_get_max_size(int window_id)

Parameters

window_id int

window_get_min_size(int)

Qualifiers: const

Returns the window's minimum size (in pixels). See also DisplayServer.window_set_min_size.

Vector2i window_get_min_size(int window_id)

Parameters

window_id int

window_get_mode(int)

Qualifiers: const

Returns the mode of the given window.

int window_get_mode(int window_id)

Parameters

window_id int

window_get_native_handle(int, int)

Qualifiers: const

Returns internal structure pointers for use in plugins.

Note: This method is implemented on Android, Linux (X11/Wayland), macOS, and Windows.

int window_get_native_handle(int handle_type, int window_id)

Parameters

handle_type int
window_id int

window_get_popup_safe_rect(int)

Qualifiers: const

Returns the bounding box of control, or menu item that was used to open the popup window, in the screen coordinate system.

Rect2i window_get_popup_safe_rect(int window)

Parameters

window int

window_get_position(int)

Qualifiers: const

Returns the position of the client area of the given window on the screen.

Vector2i window_get_position(int window_id)

Parameters

window_id int

window_get_position_with_decorations(int)

Qualifiers: const

Returns the position of the given window on the screen including the borders drawn by the operating system. See also DisplayServer.window_get_position.

Vector2i window_get_position_with_decorations(int window_id)

Parameters

window_id int

window_get_safe_title_margins(int)

Qualifiers: const

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 DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE flag is set.

Vector3i window_get_safe_title_margins(int window_id)

Parameters

window_id int

window_get_size(int)

Qualifiers: const

Returns the size of the window specified by window_id (in pixels), excluding the borders drawn by the operating system. This is also called the "client area". See also DisplayServer.window_get_size_with_decorations, DisplayServer.window_set_size and DisplayServer.window_get_position.

Vector2i window_get_size(int window_id)

Parameters

window_id int

window_get_size_with_decorations(int)

Qualifiers: const

Returns the size of the window specified by window_id (in pixels), including the borders drawn by the operating system. See also DisplayServer.window_get_size.

Vector2i window_get_size_with_decorations(int window_id)

Parameters

window_id int

window_get_title_size(String, int)

Qualifiers: const

Returns the estimated window title bar size (including text and window buttons) for the window specified by window_id (in pixels). This method does not change the window title.

Note: This method is implemented on macOS and Windows.

Vector2i window_get_title_size(String title, int window_id)

Parameters

title String
window_id int

window_get_vsync_mode(int)

Qualifiers: const

Returns the V-Sync mode of the given window.

int window_get_vsync_mode(int window_id)

Parameters

window_id int

window_is_focused(int)

Qualifiers: const

Returns true if the window specified by window_id is focused.

bool window_is_focused(int window_id)

Parameters

window_id int

window_is_maximize_allowed(int)

Qualifiers: const

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

bool window_is_maximize_allowed(int window_id)

Parameters

window_id int

window_maximize_on_title_dbl_click

Qualifiers: const

Returns true, if double-click on a window title should maximize it.

Note: This method is implemented only on macOS.

bool window_maximize_on_title_dbl_click

window_minimize_on_title_dbl_click

Qualifiers: const

Returns true, if double-click on a window title should minimize it.

Note: This method is implemented only on macOS.

bool window_minimize_on_title_dbl_click

window_move_to_foreground(int)

Moves the window specified by window_id to the foreground, so that it is visible over other windows.

void window_move_to_foreground(int window_id)

Parameters

window_id int

window_request_attention(int)

Makes the window specified by window_id 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.

void window_request_attention(int window_id)

Parameters

window_id int

window_set_current_screen(int, int)

Moves the window specified by window_id to the specified screen. See also DisplayServer.window_get_current_screen.

void window_set_current_screen(int screen, int window_id)

Parameters

screen int
window_id int

window_set_drop_files_callback(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 window_id. callback should take one PackedStringArray argument, which is the list of dropped files.

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/Wayland), and Web.

void window_set_drop_files_callback(Callable callback, int window_id)

Parameters

callback Callable
window_id int

window_set_exclusive(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.

void window_set_exclusive(int window_id, bool exclusive)

Parameters

window_id int
exclusive bool

window_set_flag(int, bool, int)

Enables or disables the given window's given flag. See WindowFlags for possible values and their behavior.

void window_set_flag(int flag, bool enabled, int window_id)

Parameters

flag int
enabled bool
window_id int

window_set_ime_active(bool, int)

Sets whether Input Method Editor should be enabled for the window specified by window_id. See also DisplayServer.window_set_ime_position.

void window_set_ime_active(bool active, int window_id)

Parameters

active bool
window_id int

window_set_ime_position(Vector2i, int)

Sets the position of the Input Method Editor popup for the specified window_id. Only effective if DisplayServer.window_set_ime_active was set to true for the specified window_id.

void window_set_ime_position(Vector2i position, int window_id)

Parameters

position Vector2i
window_id int

window_set_input_event_callback(Callable, int)

Sets the callback that should be called when any InputEvent is sent to the window specified by window_id.

Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.

void window_set_input_event_callback(Callable callback, int window_id)

Parameters

callback Callable
window_id int

window_set_input_text_callback(Callable, int)

Sets the callback that should be called when text is entered using the virtual keyboard to the window specified by window_id.

Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.

void window_set_input_text_callback(Callable callback, int window_id)

Parameters

callback Callable
window_id int

window_set_max_size(Vector2i, int)

Sets the maximum size of the window specified by window_id in pixels. Normally, the user will not be able to drag the window to make it larger than the specified size. See also DisplayServer.window_get_max_size.

Note: It's recommended to change this value using max_size instead.

Note: Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.

void window_set_max_size(Vector2i max_size, int window_id)

Parameters

max_size Vector2i
window_id int

window_set_min_size(Vector2i, int)

Sets the minimum size for the given window to min_size in pixels. Normally, the user will not be able to drag the window to make it smaller than the specified size. See also DisplayServer.window_get_min_size.

Note: It's recommended to change this value using min_size 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.

void window_set_min_size(Vector2i min_size, int window_id)

Parameters

min_size Vector2i
window_id int

window_set_mode(int, int)

Sets window mode for the given window to mode. See WindowMode for possible values and how each mode behaves.

Note: On Android, setting it to DisplayServer.WINDOW_MODE_FULLSCREEN or DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN will enable immersive mode.

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.

void window_set_mode(int mode, int window_id)

Parameters

mode int
window_id int

window_set_mouse_passthrough(PackedVector2Array, 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.window_set_mouse_passthrough($Path2D.curve.get_baked_points())

# Set region, using Polygon2D node.
DisplayServer.window_set_mouse_passthrough($Polygon2D.polygon)

# Reset region to default.
DisplayServer.window_set_mouse_passthrough([])

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.

void window_set_mouse_passthrough(PackedVector2Array region, int window_id)

Parameters

region PackedVector2Array
window_id int

window_set_popup_safe_rect(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.

void window_set_popup_safe_rect(int window, Rect2i rect)

Parameters

window int
rect Rect2i

window_set_position(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 DisplayServer.window_get_position and DisplayServer.window_set_size.

Note: It's recommended to change this value using position instead.

Note: On Linux (Wayland): this method is a no-op.

void window_set_position(Vector2i position, int window_id)

Parameters

position Vector2i
window_id int

window_set_rect_changed_callback(Callable, int)

Sets the callback that will be called when the window specified by window_id 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.

void window_set_rect_changed_callback(Callable callback, int window_id)

Parameters

callback Callable
window_id int

window_set_size(Vector2i, int)

Sets the size of the given window to size (in pixels). See also DisplayServer.window_get_size and DisplayServer.window_get_position.

Note: It's recommended to change this value using size instead.

void window_set_size(Vector2i size, int window_id)

Parameters

size Vector2i
window_id int

window_set_title(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.

void window_set_title(String title, int window_id)

Parameters

title String
window_id int

window_set_transient(int, int)

Sets window transient parent. 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: It's recommended to change this value using transient instead.

Note: The behavior might be different depending on the platform.

void window_set_transient(int window_id, int parent_window_id)

Parameters

window_id int
parent_window_id int

window_set_vsync_mode(int, int)

Sets the V-Sync mode of the given window. See also display/window/vsync/vsync_mode.

See 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 DisplayServer.VSYNC_ENABLED if the desired mode is not supported.

Note: V-Sync modes other than DisplayServer.VSYNC_ENABLED are only supported in the Forward+ and Mobile rendering methods, not Compatibility.

void window_set_vsync_mode(int vsync_mode, int window_id)

Parameters

vsync_mode int
window_id int

window_set_window_buttons_offset(Vector2i, int)

When DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE flag is set, set offset to the center of the first titlebar button.

Note: This flag is implemented only on macOS.

void window_set_window_buttons_offset(Vector2i offset, int window_id)

Parameters

offset Vector2i
window_id int

window_set_window_event_callback(Callable, int)

Sets the callback that will be called when an event occurs in the window specified by window_id.

Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.

void window_set_window_event_callback(Callable callback, int window_id)

Parameters

callback Callable
window_id int

window_start_drag(int)

Starts an interactive drag operation on the window with the given window_id, using the current mouse position. Call this method when handling a mouse button being pressed to simulate a pressed event on the window's title bar. Using this method allows the window to participate in space switching, tiling, and other system features.

Note: This method is implemented on Linux (X11/Wayland), macOS, and Windows.

void window_start_drag(int window_id)

Parameters

window_id int

window_start_resize(int, int)

Starts an interactive resize operation on the window with the given window_id, using the current mouse position. Call this method when handling a mouse button being pressed to simulate a pressed event on the window's edge.

Note: This method is implemented on Linux (X11/Wayland), macOS, and Windows.

void window_start_resize(int edge, int window_id)

Parameters

edge int
window_id int