Skip to main content

DisplayServer

Struct DisplayServer 

pub struct DisplayServer { /* private fields */ }
Expand description

Godot class DisplayServer.

Inherits Object.

Related symbols:

See also Godot docs for DisplayServer.

§Singleton

This class is a singleton. You can get the one instance using Singleton::singleton().

§Final class

This class is final, meaning you cannot inherit from it, and it comes without I* interface trait. It is still possible that other Godot classes inherit from it, but that is limited to the engine itself.

§Godot docs

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.

Implementations§

§

impl DisplayServer

pub const INVALID_SCREEN: i32 = - 1i32

pub const SCREEN_WITH_MOUSE_FOCUS: i32 = - 4i32

pub const SCREEN_WITH_KEYBOARD_FOCUS: i32 = - 3i32

pub const SCREEN_PRIMARY: i32 = - 2i32

pub const SCREEN_OF_MAIN_WINDOW: i32 = - 1i32

pub const MAIN_WINDOW_ID: i32 = 0i32

pub const INVALID_WINDOW_ID: i32 = - 1i32

pub const INVALID_INDICATOR_ID: i32 = - 1i32

pub fn has_feature(&self, feature: Feature) -> bool

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

pub fn get_name(&self) -> GString

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

pub fn help_set_search_callbacks( &mut self, search_callback: &Callable, action_callback: &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.

pub fn global_menu_set_popup_callbacks( &mut self, menu_root: impl AsArg<GString>, open_callback: &Callable, close_callback: &Callable, )

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

pub fn global_menu_add_submenu_item( &mut self, menu_root: impl AsArg<GString>, label: impl AsArg<GString>, submenu: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_submenu_item_ex and its builder methods. See the book for detailed usage instructions. 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).

pub fn global_menu_add_submenu_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, label: impl AsArg<GString> + 'ex, submenu: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddSubmenuItem<'ex>

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

pub fn global_menu_add_item( &mut self, menu_root: impl AsArg<GString>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_check_item( &mut self, menu_root: impl AsArg<GString>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_check_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_check_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddCheckItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_icon_item( &mut self, menu_root: impl AsArg<GString>, icon: impl AsArg<Option<Gd<Texture2D>>>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_icon_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_icon_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, icon: impl AsArg<Option<Gd<Texture2D>>> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddIconItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_icon_check_item( &mut self, menu_root: impl AsArg<GString>, icon: impl AsArg<Option<Gd<Texture2D>>>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_icon_check_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_icon_check_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, icon: impl AsArg<Option<Gd<Texture2D>>> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddIconCheckItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_radio_check_item( &mut self, menu_root: impl AsArg<GString>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_radio_check_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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 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).

pub fn global_menu_add_radio_check_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddRadioCheckItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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 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).

pub fn global_menu_add_icon_radio_check_item( &mut self, menu_root: impl AsArg<GString>, icon: impl AsArg<Option<Gd<Texture2D>>>, label: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_icon_radio_check_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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 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).

pub fn global_menu_add_icon_radio_check_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, icon: impl AsArg<Option<Gd<Texture2D>>> + 'ex, label: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddIconRadioCheckItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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 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).

pub fn global_menu_add_multistate_item( &mut self, menu_root: impl AsArg<GString>, label: impl AsArg<GString>, max_states: i32, default_state: i32, ) -> i32

To set the default parameters, use global_menu_add_multistate_item_ex and its builder methods. See the book for detailed usage instructions. 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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_multistate_item_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, label: impl AsArg<GString> + 'ex, max_states: i32, default_state: i32, ) -> ExGlobalMenuAddMultistateItem<'ex>

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 [enum KeyModifierMask]s and [enum Key]s 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).

pub fn global_menu_add_separator( &mut self, menu_root: impl AsArg<GString>, ) -> i32

To set the default parameters, use global_menu_add_separator_ex and its builder methods. See the book for detailed usage instructions. 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).

pub fn global_menu_add_separator_ex<'ex>( &'ex mut self, menu_root: impl AsArg<GString> + 'ex, ) -> ExGlobalMenuAddSeparator<'ex>

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

pub fn global_menu_get_item_index_from_text( &self, menu_root: impl AsArg<GString>, text: impl AsArg<GString>, ) -> i32

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.

pub fn global_menu_get_item_index_from_tag( &self, menu_root: impl AsArg<GString>, tag: &Variant, ) -> i32

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.

pub fn global_menu_is_item_checked( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> bool

Returns true if the item at index idx is checked.

Note: This method is implemented only on macOS.

pub fn global_menu_is_item_checkable( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> bool

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.

pub fn global_menu_is_item_radio_checkable( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> bool

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.

pub fn global_menu_get_item_callback( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> Callable

Returns the callback of the item at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_key_callback( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> Callable

Returns the callback of the item accelerator at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_tag( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> Variant

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_text( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> GString

Returns the text of the item at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_submenu( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> GString

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_accelerator( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> Key

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.

pub fn global_menu_is_item_disabled( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> bool

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

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

Note: This method is implemented only on macOS.

pub fn global_menu_is_item_hidden( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> bool

Returns true if the item at index idx is hidden.

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_tooltip( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> GString

Returns the tooltip associated with the specified index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_state( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> i32

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_max_states( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> i32

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_icon( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> Option<Gd<Texture2D>>

Returns the icon of the item at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_indentation_level( &self, menu_root: impl AsArg<GString>, idx: i32, ) -> i32

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

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_checked( &mut self, menu_root: impl AsArg<GString>, idx: i32, checked: bool, )

Sets the checkstate status of the item at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_checkable( &mut self, menu_root: impl AsArg<GString>, idx: i32, checkable: 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.

pub fn global_menu_set_item_radio_checkable( &mut self, menu_root: impl AsArg<GString>, idx: i32, checkable: 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.

pub fn global_menu_set_item_callback( &mut self, menu_root: impl AsArg<GString>, idx: i32, callback: &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.

pub fn global_menu_set_item_hover_callbacks( &mut self, menu_root: impl AsArg<GString>, idx: i32, callback: &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.

pub fn global_menu_set_item_key_callback( &mut self, menu_root: impl AsArg<GString>, idx: i32, key_callback: &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.

pub fn global_menu_set_item_tag( &mut self, menu_root: impl AsArg<GString>, idx: i32, tag: &Variant, )

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

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_text( &mut self, menu_root: impl AsArg<GString>, idx: i32, text: impl AsArg<GString>, )

Sets the text of the item at index idx.

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_submenu( &mut self, menu_root: impl AsArg<GString>, idx: i32, submenu: impl AsArg<GString>, )

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.

pub fn global_menu_set_item_accelerator( &mut self, menu_root: impl AsArg<GString>, idx: i32, keycode: Key, )

Sets the accelerator of the item at index idx. keycode can be a single [enum Key], or a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_disabled( &mut self, menu_root: impl AsArg<GString>, idx: i32, disabled: 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.

pub fn global_menu_set_item_hidden( &mut self, menu_root: impl AsArg<GString>, idx: i32, hidden: 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.

pub fn global_menu_set_item_tooltip( &mut self, menu_root: impl AsArg<GString>, idx: i32, tooltip: impl AsArg<GString>, )

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

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_state( &mut self, menu_root: impl AsArg<GString>, idx: i32, state: i32, )

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

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_max_states( &mut self, menu_root: impl AsArg<GString>, idx: i32, max_states: i32, )

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

Note: This method is implemented only on macOS.

pub fn global_menu_set_item_icon( &mut self, menu_root: impl AsArg<GString>, idx: i32, icon: impl AsArg<Option<Gd<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.

pub fn global_menu_set_item_indentation_level( &mut self, menu_root: impl AsArg<GString>, idx: i32, level: i32, )

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

Note: This method is implemented only on macOS.

pub fn global_menu_get_item_count(&self, menu_root: impl AsArg<GString>) -> i32

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

Note: This method is implemented only on macOS.

pub fn global_menu_remove_item( &mut self, menu_root: impl AsArg<GString>, idx: i32, )

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.

pub fn global_menu_clear(&mut self, menu_root: impl AsArg<GString>)

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

pub fn global_menu_get_system_menu_roots(&self) -> Dictionary<Variant, Variant>

Returns Dictionary of supported system menu IDs and names.

Note: This method is implemented only on macOS.

pub fn tts_is_speaking(&self) -> bool

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.

pub fn tts_is_paused(&self) -> bool

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.

pub fn tts_get_voices(&self) -> Array<Dictionary<Variant, Variant>>

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.

pub fn tts_get_voices_for_language( &self, language: impl AsArg<GString>, ) -> PackedArray<GString>

Returns a PackedStringArray of voice identifiers for the language.

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

pub fn tts_speak( &mut self, text: impl AsArg<GString>, voice: impl AsArg<GString>, )

To set the default parameters, use tts_speak_ex and its builder methods. See the book for detailed usage instructions. 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 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 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.

pub fn tts_speak_ex<'ex>( &'ex mut self, text: impl AsArg<GString> + 'ex, voice: impl AsArg<GString> + 'ex, ) -> ExTtsSpeak<'ex>

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

pub fn tts_pause(&mut self)

Puts the synthesizer into a paused state.

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

pub fn tts_resume(&mut self)

Resumes the synthesizer if it was paused.

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

pub fn tts_stop(&mut self)

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

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

pub fn tts_set_utterance_callback( &mut self, event: TtsUtteranceEvent, callable: &Callable, )

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

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.

pub fn is_dark_mode_supported(&self) -> bool

Returns true if OS supports dark mode.

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

pub fn is_dark_mode(&self) -> bool

Returns true if OS is using dark mode.

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

pub fn get_accent_color(&self) -> Color

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

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

pub fn get_base_color(&self) -> Color

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.

pub fn set_system_theme_change_callback(&mut self, callable: &Callable)

Sets the callback that should be called when the system’s theme settings are changed. callable should accept zero arguments.

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

pub fn mouse_set_mode(&mut self, mouse_mode: MouseMode)

Sets the current mouse mode. See also mouse_get_mode.

pub fn mouse_get_mode(&self) -> MouseMode

Returns the current mouse mode. See also mouse_set_mode.

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

pub fn mouse_get_position(&self) -> Vector2i

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

pub fn mouse_get_button_state(&self) -> MouseButtonMask

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.

pub fn clipboard_set(&mut self, clipboard: impl AsArg<GString>)

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

pub fn clipboard_get(&self) -> GString

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

pub fn clipboard_get_image(&self) -> Option<Gd<Image>>

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

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

pub fn clipboard_has(&self) -> bool

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

pub fn clipboard_has_image(&self) -> bool

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

pub fn clipboard_set_primary(&mut self, clipboard_primary: impl AsArg<GString>)

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

pub fn clipboard_get_primary(&self) -> GString

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

pub fn get_display_cutouts(&self) -> Array<Rect2>

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.

pub fn get_display_safe_area(&self) -> Rect2i

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

pub fn get_screen_count(&self) -> i32

Returns the number of displays available.

Note: This method is implemented on Linux (X11 and Wayland), macOS, and Windows. On other platforms, this method always returns 1.

pub fn get_primary_screen(&self) -> i32

Returns the index of the primary screen.

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns 0.

pub fn get_keyboard_focus_screen(&self) -> i32

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

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns the primary screen.

pub fn get_screen_from_rect(&self, rect: Rect2) -> i32

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

pub fn screen_get_position(&self) -> Vector2i

To set the default parameters, use screen_get_position_ex and its builder methods. See the book for detailed usage instructions. Returns the screen’s top-left corner position in pixels. Returns Vector2i.ZERO if screen is invalid. 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 might be located outside any display like this:

* (0, 0)        +-------+
                |       |
+-------------+ |       |
|             | |       |
|             | |       |
+-------------+ +-------+

See also screen_get_size.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

pub fn screen_get_position_ex<'ex>(&'ex self) -> ExScreenGetPosition<'ex>

Returns the screen’s top-left corner position in pixels. Returns Vector2i.ZERO if screen is invalid. 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 might be located outside any display like this:

* (0, 0)        +-------+
                |       |
+-------------+ |       |
|             | |       |
|             | |       |
+-------------+ +-------+

See also screen_get_size.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

pub fn screen_get_size(&self) -> Vector2i

To set the default parameters, use screen_get_size_ex and its builder methods. See the book for detailed usage instructions. Returns the screen’s size in pixels. See also screen_get_position and screen_get_usable_rect. Returns Vector2i.ZERO if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

pub fn screen_get_size_ex<'ex>(&'ex self) -> ExScreenGetSize<'ex>

Returns the screen’s size in pixels. See also screen_get_position and screen_get_usable_rect. Returns Vector2i.ZERO if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

pub fn screen_get_usable_rect(&self) -> Rect2i

To set the default parameters, use screen_get_usable_rect_ex and its builder methods. See the book for detailed usage instructions. Returns the portion of the screen that is not obstructed by a status bar in pixels. See also screen_get_size.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns Rect2i(screen_get_position(screen), screen_get_size(screen)).

pub fn screen_get_usable_rect_ex<'ex>(&'ex self) -> ExScreenGetUsableRect<'ex>

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

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns Rect2i(screen_get_position(screen), screen_get_size(screen)).

pub fn screen_get_dpi(&self) -> i32

To set the default parameters, use screen_get_dpi_ex and its builder methods. See the book for detailed usage instructions. Returns the dots per inch density of the specified screen. Returns platform specific default value if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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, iOS, Linux (X11/Wayland), macOS, Web, and Windows. On other platforms, this method always returns 72.

pub fn screen_get_dpi_ex<'ex>(&'ex self) -> ExScreenGetDpi<'ex>

Returns the dots per inch density of the specified screen. Returns platform specific default value if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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, iOS, Linux (X11/Wayland), macOS, Web, and Windows. On other platforms, this method always returns 72.

pub fn screen_get_scale(&self) -> f32

To set the default parameters, use screen_get_scale_ex and its builder methods. See the book for detailed usage instructions. Returns the scale factor of the specified screen by index. Returns 1.0 if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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). On other platforms, this method always returns 1.0.

pub fn screen_get_scale_ex<'ex>(&'ex self) -> ExScreenGetScale<'ex>

Returns the scale factor of the specified screen by index. Returns 1.0 if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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). On other platforms, this method always returns 1.0.

pub fn is_touchscreen_available(&self) -> bool

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

pub fn screen_get_max_scale(&self) -> f32

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.

pub fn screen_get_refresh_rate(&self) -> f32

To set the default parameters, use screen_get_refresh_rate_ex and its builder methods. See the book for detailed usage instructions. Returns the current refresh rate of the specified screen. When V-Sync is enabled, this returns the maximum framerate the project can effectively reach. Returns -1.0 if screen is invalid or the DisplayServer fails to find the refresh rate for the specified screen.

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

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Android, iOS, macOS, Linux (X11 and Wayland), and Windows. On other platforms, this method always returns -1.0.

pub fn screen_get_refresh_rate_ex<'ex>(&'ex self) -> ExScreenGetRefreshRate<'ex>

Returns the current refresh rate of the specified screen. When V-Sync is enabled, this returns the maximum framerate the project can effectively reach. Returns -1.0 if screen is invalid or the DisplayServer fails to find the refresh rate for the specified screen.

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

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Android, iOS, macOS, Linux (X11 and Wayland), and Windows. On other platforms, this method always returns -1.0.

pub fn screen_get_pixel(&self, position: Vector2i) -> Color

Returns the color of the pixel at the given screen position. On multi-monitor setups, the screen position is relative to the virtual desktop area.

Note: This method is implemented on Linux (X11, excluding XWayland), macOS, and Windows. On other platforms, this method always returns Color(0, 0, 0, 1).

Note: On macOS, this method requires the “Screen Recording” permission. If permission is not granted, this method returns a color from a screenshot that will not include other application windows or OS elements not related to the application.

pub fn screen_get_image(&self) -> Option<Gd<Image>>

To set the default parameters, use screen_get_image_ex and its builder methods. See the book for detailed usage instructions. Returns a screenshot of the screen. Returns null if screen is invalid or the DisplayServer fails to capture screenshot.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Linux (X11, excluding XWayland), macOS, and Windows. On other platforms, this method always returns null.

Note: On macOS, this method requires the “Screen Recording” permission. If permission is not granted, this method returns a screenshot that will not include other application windows or OS elements not related to the application.

pub fn screen_get_image_ex<'ex>(&'ex self) -> ExScreenGetImage<'ex>

Returns a screenshot of the screen. Returns null if screen is invalid or the DisplayServer fails to capture screenshot.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Linux (X11, excluding XWayland), macOS, and Windows. On other platforms, this method always returns null.

Note: On macOS, this method requires the “Screen Recording” permission. If permission is not granted, this method returns a screenshot that will not include other application windows or OS elements not related to the application.

pub fn screen_get_image_rect(&self, rect: Rect2i) -> Option<Gd<Image>>

Returns a screenshot of the screen region defined by rect. Returns null if rect is outside screen bounds or the DisplayServer fails to capture screenshot.

Note: This method is implemented on macOS and Windows. On other platforms, this method always returns null.

Note: On macOS, this method requires the “Screen Recording” permission. If permission is not granted, this method returns a screenshot that will not include other application windows or OS elements not related to the application.

pub fn screen_set_orientation(&mut self, orientation: ScreenOrientation)

To set the default parameters, use screen_set_orientation_ex and its builder methods. See the book for detailed usage instructions. Sets the screen’s orientation. See also screen_get_orientation.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Android and iOS.

Note: On iOS, this method has no effect if [member ProjectSettings.display/window/handheld/orientation] is not set to ScreenOrientation::SENSOR.

pub fn screen_set_orientation_ex<'ex>( &'ex mut self, orientation: ScreenOrientation, ) -> ExScreenSetOrientation<'ex>

Sets the screen’s orientation. See also screen_get_orientation.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

Note: This method is implemented on Android and iOS.

Note: On iOS, this method has no effect if [member ProjectSettings.display/window/handheld/orientation] is not set to ScreenOrientation::SENSOR.

pub fn screen_get_orientation(&self) -> ScreenOrientation

To set the default parameters, use screen_get_orientation_ex and its builder methods. See the book for detailed usage instructions. Returns the screen’s current orientation. See also screen_set_orientation. Returns ScreenOrientation::LANDSCAPE if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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

pub fn screen_get_orientation_ex<'ex>(&'ex self) -> ExScreenGetOrientation<'ex>

Returns the screen’s current orientation. See also screen_set_orientation. Returns ScreenOrientation::LANDSCAPE if screen is invalid.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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

pub fn screen_set_keep_on(&mut self, enable: bool)

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

pub fn screen_is_kept_on(&self) -> bool

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

pub fn get_window_list(&self) -> PackedArray<i32>

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

Note: Native dialogs are not included in this list.

pub fn get_window_at_screen_position(&self, position: Vector2i) -> i32

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

pub fn window_get_native_handle(&self, handle_type: HandleType) -> i64

To set the default parameters, use window_get_native_handle_ex and its builder methods. See the book for detailed usage instructions. Returns internal structure pointers for use in plugins.

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

pub fn window_get_native_handle_ex<'ex>( &'ex self, handle_type: HandleType, ) -> ExWindowGetNativeHandle<'ex>

Returns internal structure pointers for use in plugins.

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

pub fn window_get_active_popup(&self) -> i32

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

pub fn window_set_popup_safe_rect(&mut self, window: i32, rect: 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.

pub fn window_get_popup_safe_rect(&self, window: i32) -> Rect2i

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

pub fn window_set_title(&mut self, title: impl AsArg<GString>)

To set the default parameters, use window_set_title_ex and its builder methods. See the book for detailed usage instructions. Sets the title of the given window to title.

Note: It’s recommended to change this value using [member Window.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.

pub fn window_set_title_ex<'ex>( &'ex mut self, title: impl AsArg<GString> + 'ex, ) -> ExWindowSetTitle<'ex>

Sets the title of the given window to title.

Note: It’s recommended to change this value using [member Window.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.

pub fn window_get_title_size(&self, title: impl AsArg<GString>) -> Vector2i

To set the default parameters, use window_get_title_size_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_get_title_size_ex<'ex>( &'ex self, title: impl AsArg<GString> + 'ex, ) -> ExWindowGetTitleSize<'ex>

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.

pub fn window_set_mouse_passthrough(&mut self, region: &PackedArray<Vector2>)

To set the default parameters, use window_set_mouse_passthrough_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_mouse_passthrough_ex<'ex>( &'ex mut self, region: &'ex PackedArray<Vector2>, ) -> ExWindowSetMousePassthrough<'ex>

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.

pub fn window_get_current_screen(&self) -> i32

To set the default parameters, use window_get_current_screen_ex and its builder methods. See the book for detailed usage instructions. 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 window_set_current_screen. Returns INVALID_SCREEN if window_id is invalid.

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns 0.

pub fn window_get_current_screen_ex<'ex>( &'ex self, ) -> ExWindowGetCurrentScreen<'ex>

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 window_set_current_screen. Returns INVALID_SCREEN if window_id is invalid.

Note: This method is implemented on Linux/X11, macOS, and Windows. On other platforms, this method always returns 0.

pub fn window_set_current_screen(&mut self, screen: i32)

To set the default parameters, use window_set_current_screen_ex and its builder methods. See the book for detailed usage instructions. Moves the window specified by window_id to the specified screen. See also window_get_current_screen.

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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

pub fn window_set_current_screen_ex<'ex>( &'ex mut self, screen: i32, ) -> ExWindowSetCurrentScreen<'ex>

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

Note: One of the following constants can be used as screen: SCREEN_OF_MAIN_WINDOW, SCREEN_PRIMARY, SCREEN_WITH_MOUSE_FOCUS, or SCREEN_WITH_KEYBOARD_FOCUS.

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

pub fn window_get_position(&self) -> Vector2i

To set the default parameters, use window_get_position_ex and its builder methods. See the book for detailed usage instructions. Returns the position of the client area of the given window on the screen.

pub fn window_get_position_ex<'ex>(&'ex self) -> ExWindowGetPosition<'ex>

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

pub fn window_get_position_with_decorations(&self) -> Vector2i

To set the default parameters, use window_get_position_with_decorations_ex and its builder methods. See the book for detailed usage instructions. Returns the position of the given window on the screen including the borders drawn by the operating system. See also window_get_position.

pub fn window_get_position_with_decorations_ex<'ex>( &'ex self, ) -> ExWindowGetPositionWithDecorations<'ex>

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

pub fn window_set_position(&mut self, position: Vector2i)

To set the default parameters, use window_set_position_ex and its builder methods. See the book for detailed usage instructions. 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 window_get_position and window_set_size.

Note: It’s recommended to change this value using [member Window.position] instead.

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

pub fn window_set_position_ex<'ex>( &'ex mut self, position: Vector2i, ) -> ExWindowSetPosition<'ex>

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

Note: It’s recommended to change this value using [member Window.position] instead.

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

pub fn window_get_size(&self) -> Vector2i

To set the default parameters, use window_get_size_ex and its builder methods. See the book for detailed usage instructions. 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 window_get_size_with_decorations, window_set_size and window_get_position.

pub fn window_get_size_ex<'ex>(&'ex self) -> ExWindowGetSize<'ex>

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 window_get_size_with_decorations, window_set_size and window_get_position.

pub fn window_set_size(&mut self, size: Vector2i)

To set the default parameters, use window_set_size_ex and its builder methods. See the book for detailed usage instructions. Sets the size of the given window to size (in pixels). See also window_get_size and window_get_position.

Note: It’s recommended to change this value using [member Window.size] instead.

pub fn window_set_size_ex<'ex>( &'ex mut self, size: Vector2i, ) -> ExWindowSetSize<'ex>

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

Note: It’s recommended to change this value using [member Window.size] instead.

pub fn window_set_rect_changed_callback(&mut self, callback: &Callable)

To set the default parameters, use window_set_rect_changed_callback_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_rect_changed_callback_ex<'ex>( &'ex mut self, callback: &'ex Callable, ) -> ExWindowSetRectChangedCallback<'ex>

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.

pub fn window_set_window_event_callback(&mut self, callback: &Callable)

To set the default parameters, use window_set_window_event_callback_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_window_event_callback_ex<'ex>( &'ex mut self, callback: &'ex Callable, ) -> ExWindowSetWindowEventCallback<'ex>

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.

pub fn window_set_input_event_callback(&mut self, callback: &Callable)

To set the default parameters, use window_set_input_event_callback_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_input_event_callback_ex<'ex>( &'ex mut self, callback: &'ex Callable, ) -> ExWindowSetInputEventCallback<'ex>

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.

pub fn window_set_input_text_callback(&mut self, callback: &Callable)

To set the default parameters, use window_set_input_text_callback_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_input_text_callback_ex<'ex>( &'ex mut self, callback: &'ex Callable, ) -> ExWindowSetInputTextCallback<'ex>

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.

pub fn window_set_drop_files_callback(&mut self, callback: &Callable)

To set the default parameters, use window_set_drop_files_callback_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_set_drop_files_callback_ex<'ex>( &'ex mut self, callback: &'ex Callable, ) -> ExWindowSetDropFilesCallback<'ex>

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.

pub fn window_get_attached_instance_id(&self) -> u64

To set the default parameters, use window_get_attached_instance_id_ex and its builder methods. See the book for detailed usage instructions. Returns the instance_id of the Window the window_id is attached to.

pub fn window_get_attached_instance_id_ex<'ex>( &'ex self, ) -> ExWindowGetAttachedInstanceId<'ex>

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

pub fn window_get_max_size(&self) -> Vector2i

To set the default parameters, use window_get_max_size_ex and its builder methods. See the book for detailed usage instructions. Returns the window’s maximum size (in pixels). See also window_set_max_size.

pub fn window_get_max_size_ex<'ex>(&'ex self) -> ExWindowGetMaxSize<'ex>

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

pub fn window_set_max_size(&mut self, max_size: Vector2i)

To set the default parameters, use window_set_max_size_ex and its builder methods. See the book for detailed usage instructions. 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 window_get_max_size.

Note: It’s recommended to change this value using [member Window.max_size] instead.

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

pub fn window_set_max_size_ex<'ex>( &'ex mut self, max_size: Vector2i, ) -> ExWindowSetMaxSize<'ex>

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

Note: It’s recommended to change this value using [member Window.max_size] instead.

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

pub fn window_get_min_size(&self) -> Vector2i

To set the default parameters, use window_get_min_size_ex and its builder methods. See the book for detailed usage instructions. Returns the window’s minimum size (in pixels). See also window_set_min_size.

pub fn window_get_min_size_ex<'ex>(&'ex self) -> ExWindowGetMinSize<'ex>

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

pub fn window_set_min_size(&mut self, min_size: Vector2i)

To set the default parameters, use window_set_min_size_ex and its builder methods. See the book for detailed usage instructions. 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 window_get_min_size.

Note: It’s recommended to change this value using [member Window.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.

pub fn window_set_min_size_ex<'ex>( &'ex mut self, min_size: Vector2i, ) -> ExWindowSetMinSize<'ex>

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

Note: It’s recommended to change this value using [member Window.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.

pub fn window_get_size_with_decorations(&self) -> Vector2i

To set the default parameters, use window_get_size_with_decorations_ex and its builder methods. See the book for detailed usage instructions. Returns the size of the window specified by window_id (in pixels), including the borders drawn by the operating system. See also window_get_size.

pub fn window_get_size_with_decorations_ex<'ex>( &'ex self, ) -> ExWindowGetSizeWithDecorations<'ex>

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

pub fn window_get_mode(&self) -> WindowMode

To set the default parameters, use window_get_mode_ex and its builder methods. See the book for detailed usage instructions. Returns the mode of the given window.

pub fn window_get_mode_ex<'ex>(&'ex self) -> ExWindowGetMode<'ex>

Returns the mode of the given window.

pub fn window_set_mode(&mut self, mode: WindowMode)

To set the default parameters, use window_set_mode_ex and its builder methods. See the book for detailed usage instructions. Sets window mode for the given window to mode.

Note: On Android, setting it to WindowMode::FULLSCREEN or WindowMode::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.

pub fn window_set_mode_ex<'ex>( &'ex mut self, mode: WindowMode, ) -> ExWindowSetMode<'ex>

Sets window mode for the given window to mode.

Note: On Android, setting it to WindowMode::FULLSCREEN or WindowMode::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.

pub fn window_set_flag(&mut self, flag: WindowFlags, enabled: bool)

To set the default parameters, use window_set_flag_ex and its builder methods. See the book for detailed usage instructions. Enables or disables the given window’s given flag.

pub fn window_set_flag_ex<'ex>( &'ex mut self, flag: WindowFlags, enabled: bool, ) -> ExWindowSetFlag<'ex>

Enables or disables the given window’s given flag.

pub fn window_get_flag(&self, flag: WindowFlags) -> bool

To set the default parameters, use window_get_flag_ex and its builder methods. See the book for detailed usage instructions. Returns the current value of the given window’s flag.

pub fn window_get_flag_ex<'ex>( &'ex self, flag: WindowFlags, ) -> ExWindowGetFlag<'ex>

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

pub fn window_set_window_buttons_offset(&mut self, offset: Vector2i)

To set the default parameters, use window_set_window_buttons_offset_ex and its builder methods. See the book for detailed usage instructions. When WindowFlags::EXTEND_TO_TITLE flag is set, set offset to the center of the first titlebar button.

Note: This flag is implemented only on macOS.

pub fn window_set_window_buttons_offset_ex<'ex>( &'ex mut self, offset: Vector2i, ) -> ExWindowSetWindowButtonsOffset<'ex>

When WindowFlags::EXTEND_TO_TITLE flag is set, set offset to the center of the first titlebar button.

Note: This flag is implemented only on macOS.

pub fn window_get_safe_title_margins(&self) -> Vector3i

To set the default parameters, use window_get_safe_title_margins_ex and its builder methods. See the book for detailed usage instructions. 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 WindowFlags::EXTEND_TO_TITLE flag is set.

pub fn window_get_safe_title_margins_ex<'ex>( &'ex self, ) -> ExWindowGetSafeTitleMargins<'ex>

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 WindowFlags::EXTEND_TO_TITLE flag is set.

pub fn window_request_attention(&mut self)

To set the default parameters, use window_request_attention_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_request_attention_ex<'ex>( &'ex mut self, ) -> ExWindowRequestAttention<'ex>

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.

pub fn window_move_to_foreground(&mut self)

To set the default parameters, use window_move_to_foreground_ex and its builder methods. See the book for detailed usage instructions. Moves the window specified by window_id to the foreground, so that it is visible over other windows.

pub fn window_move_to_foreground_ex<'ex>( &'ex mut self, ) -> ExWindowMoveToForeground<'ex>

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

pub fn window_is_focused(&self) -> bool

To set the default parameters, use window_is_focused_ex and its builder methods. See the book for detailed usage instructions. Returns true if the window specified by window_id is focused.

pub fn window_is_focused_ex<'ex>(&'ex self) -> ExWindowIsFocused<'ex>

Returns true if the window specified by window_id is focused.

pub fn window_can_draw(&self) -> bool

To set the default parameters, use window_can_draw_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_can_draw_ex<'ex>(&'ex self) -> ExWindowCanDraw<'ex>

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.

pub fn window_set_transient(&mut self, window_id: i32, parent_window_id: i32)

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 [member Window.transient] instead.

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

pub fn window_set_exclusive(&mut self, window_id: i32, exclusive: 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.

pub fn window_set_ime_active(&mut self, active: bool)

To set the default parameters, use window_set_ime_active_ex and its builder methods. See the book for detailed usage instructions. Sets whether Input Method Editor should be enabled for the window specified by window_id. See also window_set_ime_position.

pub fn window_set_ime_active_ex<'ex>( &'ex mut self, active: bool, ) -> ExWindowSetImeActive<'ex>

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

pub fn window_set_ime_position(&mut self, position: Vector2i)

To set the default parameters, use window_set_ime_position_ex and its builder methods. See the book for detailed usage instructions. Sets the position of the Input Method Editor popup for the specified window_id. Only effective if window_set_ime_active was set to true for the specified window_id.

pub fn window_set_ime_position_ex<'ex>( &'ex mut self, position: Vector2i, ) -> ExWindowSetImePosition<'ex>

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

pub fn window_set_vsync_mode(&mut self, vsync_mode: VSyncMode)

To set the default parameters, use window_set_vsync_mode_ex and its builder methods. See the book for detailed usage instructions. Sets the V-Sync mode of the given window. See also [member ProjectSettings.display/window/vsync/vsync_mode].

Depending on the platform and used renderer, the engine will fall back to VSyncMode::ENABLED if the desired mode is not supported.

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

pub fn window_set_vsync_mode_ex<'ex>( &'ex mut self, vsync_mode: VSyncMode, ) -> ExWindowSetVSyncMode<'ex>

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

Depending on the platform and used renderer, the engine will fall back to VSyncMode::ENABLED if the desired mode is not supported.

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

pub fn window_get_vsync_mode(&self) -> VSyncMode

To set the default parameters, use window_get_vsync_mode_ex and its builder methods. See the book for detailed usage instructions. Returns the V-Sync mode of the given window.

pub fn window_get_vsync_mode_ex<'ex>(&'ex self) -> ExWindowGetVSyncMode<'ex>

Returns the V-Sync mode of the given window.

pub fn window_is_maximize_allowed(&self) -> bool

To set the default parameters, use window_is_maximize_allowed_ex and its builder methods. See the book for detailed usage instructions. Returns true if the given window can be maximized (the maximize button is enabled).

pub fn window_is_maximize_allowed_ex<'ex>( &'ex self, ) -> ExWindowIsMaximizeAllowed<'ex>

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

pub fn window_maximize_on_title_dbl_click(&self) -> bool

Returns true if double-clicking on a window’s title should maximize it.

Note: This method is implemented only on macOS.

pub fn window_minimize_on_title_dbl_click(&self) -> bool

Returns true if double-clicking on a window’s title should minimize it.

Note: This method is implemented only on macOS.

pub fn window_start_drag(&mut self)

To set the default parameters, use window_start_drag_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_start_drag_ex<'ex>(&'ex mut self) -> ExWindowStartDrag<'ex>

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.

pub fn window_start_resize(&mut self, edge: WindowResizeEdge)

To set the default parameters, use window_start_resize_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn window_start_resize_ex<'ex>( &'ex mut self, edge: WindowResizeEdge, ) -> ExWindowStartResize<'ex>

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.

pub fn window_set_color(&mut self, color: Color)

Sets the background color of the root window.

Note: This method is implemented only on Android.

pub fn accessibility_should_increase_contrast(&self) -> i32

Returns 1 if a high-contrast user interface theme should be used, 0 otherwise. Returns -1 if status is unknown.

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

pub fn accessibility_should_reduce_animation(&self) -> i32

Returns 1 if flashing, blinking, and other moving content that can cause seizures in users with photosensitive epilepsy should be disabled, 0 otherwise. Returns -1 if status is unknown.

Note: This method is implemented on macOS and Windows.

pub fn accessibility_should_reduce_transparency(&self) -> i32

Returns 1 if background images, transparency, and other features that can reduce the contrast between the foreground and background should be disabled, 0 otherwise. Returns -1 if status is unknown.

Note: This method is implemented on macOS and Windows.

pub fn accessibility_screen_reader_active(&self) -> i32

Returns 1 if a screen reader, Braille display or other assistive app is active, 0 otherwise. Returns -1 if status is unknown.

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

Note: Accessibility debugging tools, such as Accessibility Insights for Windows, Accessibility Inspector (macOS), or AT-SPI Browser (Linux/BSD), do not count as assistive apps and will not affect this value. To test your project with these tools, set [member ProjectSettings.accessibility/general/accessibility_support] to 1.

pub fn accessibility_create_element( &mut self, window_id: i32, role: AccessibilityRole, ) -> Rid

Creates a new, empty accessibility element resource.

Note: An accessibility element is created and freed automatically for each Node. In general, this function should not be called manually.

pub fn accessibility_create_sub_element( &mut self, parent_rid: Rid, role: AccessibilityRole, ) -> Rid

To set the default parameters, use accessibility_create_sub_element_ex and its builder methods. See the book for detailed usage instructions. Creates a new, empty accessibility sub-element resource. Sub-elements can be used to provide accessibility information for objects which are not Nodes, such as list items, table cells, or menu items. Sub-elements are freed automatically when the parent element is freed, or can be freed early using the accessibility_free_element method.

pub fn accessibility_create_sub_element_ex<'ex>( &'ex mut self, parent_rid: Rid, role: AccessibilityRole, ) -> ExAccessibilityCreateSubElement<'ex>

Creates a new, empty accessibility sub-element resource. Sub-elements can be used to provide accessibility information for objects which are not Nodes, such as list items, table cells, or menu items. Sub-elements are freed automatically when the parent element is freed, or can be freed early using the accessibility_free_element method.

pub fn accessibility_create_sub_text_edit_elements( &mut self, parent_rid: Rid, shaped_text: Rid, min_height: f32, ) -> Rid

To set the default parameters, use accessibility_create_sub_text_edit_elements_ex and its builder methods. See the book for detailed usage instructions. Creates a new, empty accessibility sub-element from the shaped text buffer. Sub-elements are freed automatically when the parent element is freed, or can be freed early using the accessibility_free_element method.

If is_last_line is true, no trailing newline is appended to the text content. Set to true for the last line in multi-line text fields and for single-line text fields.

pub fn accessibility_create_sub_text_edit_elements_ex<'ex>( &'ex mut self, parent_rid: Rid, shaped_text: Rid, min_height: f32, ) -> ExAccessibilityCreateSubTextEditElements<'ex>

Creates a new, empty accessibility sub-element from the shaped text buffer. Sub-elements are freed automatically when the parent element is freed, or can be freed early using the accessibility_free_element method.

If is_last_line is true, no trailing newline is appended to the text content. Set to true for the last line in multi-line text fields and for single-line text fields.

pub fn accessibility_has_element(&self, id: Rid) -> bool

Returns true if id is a valid accessibility element.

pub fn accessibility_free_element(&mut self, id: Rid)

pub fn accessibility_element_set_meta(&mut self, id: Rid, meta: &Variant)

Sets the metadata of the accessibility element id to meta.

pub fn accessibility_element_get_meta(&self, id: Rid) -> Variant

Returns the metadata of the accessibility element id.

pub fn accessibility_set_window_rect( &mut self, window_id: i32, rect_out: Rect2, rect_in: Rect2, )

Sets window outer (with decorations) and inner (without decorations) bounds for assistive apps.

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

Note: Advanced users only! Window objects call this method automatically.

pub fn accessibility_set_window_focused( &mut self, window_id: i32, focused: bool, )

Sets the window focused state for assistive apps.

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

Note: Advanced users only! Window objects call this method automatically.

pub fn accessibility_update_set_focus(&mut self, id: Rid)

Sets currently focused element.

pub fn accessibility_get_window_root(&self, window_id: i32) -> Rid

Returns the main accessibility element of the OS native window.

pub fn accessibility_update_set_role( &mut self, id: Rid, role: AccessibilityRole, )

Sets element accessibility role.

pub fn accessibility_update_set_name( &mut self, id: Rid, name: impl AsArg<GString>, )

Sets element accessibility name.

pub fn accessibility_update_set_extra_info( &mut self, id: Rid, name: impl AsArg<GString>, )

Sets element accessibility extra information added to the element name.

pub fn accessibility_update_set_description( &mut self, id: Rid, description: impl AsArg<GString>, )

Sets element accessibility description.

pub fn accessibility_update_set_value( &mut self, id: Rid, value: impl AsArg<GString>, )

Sets element text value.

pub fn accessibility_update_set_tooltip( &mut self, id: Rid, tooltip: impl AsArg<GString>, )

Sets tooltip text.

pub fn accessibility_update_set_bounds(&mut self, id: Rid, p_rect: Rect2)

Sets element bounding box, relative to the node position.

pub fn accessibility_update_set_transform( &mut self, id: Rid, transform: Transform2D, )

Sets element 2D transform.

pub fn accessibility_update_add_child(&mut self, id: Rid, child_id: Rid)

Adds a child accessibility element.

Note: Node children and sub-elements are added to the child list automatically.

Adds an element that is controlled by this element.

Adds an element that details this element.

Adds an element that describes this element.

Adds an element that this element flow into.

Adds an element that labels this element.

Adds an element that is part of the same radio group.

Note: This method should be called on each element of the group, using all other elements as related_id.

pub fn accessibility_update_set_active_descendant( &mut self, id: Rid, other_id: Rid, )

Adds an element that is an active descendant of this element.

pub fn accessibility_update_set_next_on_line(&mut self, id: Rid, other_id: Rid)

Sets next element on the line.

pub fn accessibility_update_set_previous_on_line( &mut self, id: Rid, other_id: Rid, )

Sets previous element on the line.

pub fn accessibility_update_set_member_of(&mut self, id: Rid, group_id: Rid)

Sets the element to be a member of the group.

Sets target element for the link.

pub fn accessibility_update_set_error_message(&mut self, id: Rid, other_id: Rid)

Sets an element which contains an error message for this element.

pub fn accessibility_update_set_live( &mut self, id: Rid, live: AccessibilityLiveMode, )

Sets the priority of the live region updates.

pub fn accessibility_update_add_action( &mut self, id: Rid, action: AccessibilityAction, callable: &Callable, )

Adds a callback for the accessibility action (action which can be performed by using a special screen reader command or buttons on the Braille display), and marks this action as supported. The action callback receives one Variant argument, which value depends on action type.

pub fn accessibility_update_add_custom_action( &mut self, id: Rid, action_id: i32, action_description: impl AsArg<GString>, )

Adds support for a custom accessibility action. action_id is passed as an argument to the callback of AccessibilityAction::CUSTOM action.

pub fn accessibility_update_set_table_row_count(&mut self, id: Rid, count: i32)

Sets number of rows in the table.

pub fn accessibility_update_set_table_column_count( &mut self, id: Rid, count: i32, )

Sets number of columns in the table.

pub fn accessibility_update_set_table_row_index(&mut self, id: Rid, index: i32)

Sets position of the row in the table.

pub fn accessibility_update_set_table_column_index( &mut self, id: Rid, index: i32, )

Sets position of the column.

pub fn accessibility_update_set_table_cell_position( &mut self, id: Rid, row_index: i32, column_index: i32, )

Sets cell position in the table.

pub fn accessibility_update_set_table_cell_span( &mut self, id: Rid, row_span: i32, column_span: i32, )

Sets cell row/column span.

pub fn accessibility_update_set_list_item_count(&mut self, id: Rid, size: i32)

Sets number of items in the list.

pub fn accessibility_update_set_list_item_index(&mut self, id: Rid, index: i32)

Sets the position of the element in the list.

pub fn accessibility_update_set_list_item_level(&mut self, id: Rid, level: i32)

Sets the hierarchical level of the element in the list.

pub fn accessibility_update_set_list_item_selected( &mut self, id: Rid, selected: bool, )

Sets list/tree item selected status.

pub fn accessibility_update_set_list_item_expanded( &mut self, id: Rid, expanded: bool, )

Sets list/tree item expanded status.

pub fn accessibility_update_set_popup_type( &mut self, id: Rid, popup: AccessibilityPopupType, )

Sets popup type for popup buttons.

pub fn accessibility_update_set_checked(&mut self, id: Rid, checekd: bool)

Sets element checked state.

pub fn accessibility_update_set_num_value(&mut self, id: Rid, position: f64)

Sets numeric value.

pub fn accessibility_update_set_num_range( &mut self, id: Rid, min: f64, max: f64, )

Sets numeric value range.

pub fn accessibility_update_set_num_step(&mut self, id: Rid, step: f64)

Sets numeric value step.

pub fn accessibility_update_set_num_jump(&mut self, id: Rid, jump: f64)

Sets numeric value jump.

pub fn accessibility_update_set_scroll_x(&mut self, id: Rid, position: f64)

Sets scroll bar x position.

pub fn accessibility_update_set_scroll_x_range( &mut self, id: Rid, min: f64, max: f64, )

Sets scroll bar x range.

pub fn accessibility_update_set_scroll_y(&mut self, id: Rid, position: f64)

Sets scroll bar y position.

pub fn accessibility_update_set_scroll_y_range( &mut self, id: Rid, min: f64, max: f64, )

Sets scroll bar y range.

pub fn accessibility_update_set_text_decorations( &mut self, id: Rid, underline: bool, strikethrough: bool, overline: bool, )

Sets text underline/overline/strikethrough.

pub fn accessibility_update_set_text_align( &mut self, id: Rid, align: HorizontalAlignment, )

Sets element text alignment.

pub fn accessibility_update_set_text_selection( &mut self, id: Rid, text_start_id: Rid, start_char: i32, text_end_id: Rid, end_char: i32, )

Sets text selection to the text field. text_start_id and text_end_id should be elements created by accessibility_create_sub_text_edit_elements. Character offsets are relative to the corresponding element.

pub fn accessibility_update_set_flag( &mut self, id: Rid, flag: AccessibilityFlags, value: bool, )

Sets element flag.

pub fn accessibility_update_set_classname( &mut self, id: Rid, classname: impl AsArg<GString>, )

Sets element class name.

pub fn accessibility_update_set_placeholder( &mut self, id: Rid, placeholder: impl AsArg<GString>, )

Sets placeholder text.

pub fn accessibility_update_set_language( &mut self, id: Rid, language: impl AsArg<GString>, )

Sets element text language.

pub fn accessibility_update_set_text_orientation( &mut self, id: Rid, vertical: bool, )

Sets text orientation.

pub fn accessibility_update_set_list_orientation( &mut self, id: Rid, vertical: bool, )

Sets the orientation of the list elements.

pub fn accessibility_update_set_shortcut( &mut self, id: Rid, shortcut: impl AsArg<GString>, )

Sets the list of keyboard shortcuts used by element.

pub fn accessibility_update_set_url( &mut self, id: Rid, url: impl AsArg<GString>, )

Sets link URL.

pub fn accessibility_update_set_role_description( &mut self, id: Rid, description: impl AsArg<GString>, )

Sets element accessibility role description text.

pub fn accessibility_update_set_state_description( &mut self, id: Rid, description: impl AsArg<GString>, )

Sets human-readable description of the current checked state.

pub fn accessibility_update_set_color_value(&mut self, id: Rid, color: Color)

Sets element color value.

pub fn accessibility_update_set_background_color( &mut self, id: Rid, color: Color, )

Sets element background color.

pub fn accessibility_update_set_foreground_color( &mut self, id: Rid, color: Color, )

Sets element foreground color.

pub fn ime_get_selection(&self) -> Vector2i

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.

pub fn ime_get_text(&self) -> GString

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

Note: This method is implemented only on macOS.

pub fn virtual_keyboard_show(&mut self, existing_text: impl AsArg<GString>)

To set the default parameters, use virtual_keyboard_show_ex and its builder methods. See the book for detailed usage instructions. 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.

pub fn virtual_keyboard_show_ex<'ex>( &'ex mut self, existing_text: impl AsArg<GString> + 'ex, ) -> ExVirtualKeyboardShow<'ex>

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.

pub fn virtual_keyboard_hide(&mut self)

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

pub fn virtual_keyboard_get_height(&self) -> i32

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

Note: On Android 7 and 8, the keyboard height may return 0 the first time the keyboard is opened in non-immersive mode. This behavior does not occur in immersive mode.

pub fn has_hardware_keyboard(&self) -> bool

Returns true if a hardware keyboard is connected.

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

pub fn set_hardware_keyboard_connection_change_callback( &mut self, callable: &Callable, )

Sets the callback that should be called when a hardware keyboard is connected or disconnected. callable should accept a single bool argument indicating whether the keyboard has been connected (true) or disconnected (false).

Note: This method is only implemented on Android.

pub fn cursor_set_shape(&mut self, shape: 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 cursor_get_shape and cursor_set_custom_image.

pub fn cursor_get_shape(&self) -> CursorShape

Returns the default mouse cursor shape set by cursor_set_shape.

pub fn cursor_set_custom_image( &mut self, cursor: impl AsArg<Option<Gd<Resource>>>, )

To set the default parameters, use cursor_set_custom_image_ex and its builder methods. See the book for detailed usage instructions. 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 cursor_set_shape.

Note: On Web, calling this method every frame can cause the cursor to flicker.

pub fn cursor_set_custom_image_ex<'ex>( &'ex mut self, cursor: impl AsArg<Option<Gd<Resource>>> + 'ex, ) -> ExCursorSetCustomImage<'ex>

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

Note: On Web, calling this method every frame can cause the cursor to flicker.

pub fn get_swap_cancel_ok(&self) -> bool

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 [member ProjectSettings.gui/common/swap_cancel_ok].

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

pub fn enable_for_stealing_focus(&mut self, process_id: i64)

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.

pub fn dialog_show( &mut self, title: impl AsArg<GString>, description: impl AsArg<GString>, buttons: &PackedArray<GString>, callback: &Callable, ) -> Error

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 Feature::NATIVE_DIALOG feature. Supported platforms include macOS, Windows, and Android.

pub fn dialog_input_text( &mut self, title: impl AsArg<GString>, description: impl AsArg<GString>, existing_text: impl AsArg<GString>, callback: &Callable, ) -> Error

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 Feature::NATIVE_DIALOG_INPUT feature. Supported platforms include macOS, Windows, and Android.

pub fn file_dialog_show( &mut self, title: impl AsArg<GString>, current_directory: impl AsArg<GString>, filename: impl AsArg<GString>, show_hidden: bool, mode: FileDialogMode, filters: &PackedArray<GString>, callback: &Callable, ) -> Error

To set the default parameters, use file_dialog_show_ex and its builder methods. See the book for detailed usage instructions. 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 [member FileDialog.filters].

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

Note: This method is implemented if the display server has the Feature::NATIVE_DIALOG_FILE feature. Supported platforms include Linux (X11/Wayland), Windows, macOS, and Android (API level 29+).

Note: current_directory might be ignored.

Note: Embedded file dialogs and Windows file dialogs 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.

Note: On Android, this method uses the Android Storage Access Framework (SAF).

The file picker returns a URI instead of a filesystem path. This URI can be passed directly to FileAccess to perform read/write operations.

When using FileDialogMode::OPEN_DIR, it returns a tree URI that grants full access to the selected directory. File operations inside this directory can be performed by passing a path on the form treeUri#relative/path/to/file to FileAccess.

To avoid opening the file picker again after each app restart, you can take persistable URI permission as follows:

val uri = "content://com.android..." # URI of the selected file or folder.
val persist = true # Set to false to release the persistable permission.
var android_runtime = Engine.get_singleton("AndroidRuntime")
android_runtime.updatePersistableUriPermission(uri, persist)

The persistable URI permission remains valid across app restarts as long as the directory is not moved, renamed, or deleted.

pub fn file_dialog_show_ex<'ex>( &'ex mut self, title: impl AsArg<GString> + 'ex, current_directory: impl AsArg<GString> + 'ex, filename: impl AsArg<GString> + 'ex, show_hidden: bool, mode: FileDialogMode, filters: &'ex PackedArray<GString>, callback: &'ex Callable, ) -> ExFileDialogShow<'ex>

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 [member FileDialog.filters].

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

Note: This method is implemented if the display server has the Feature::NATIVE_DIALOG_FILE feature. Supported platforms include Linux (X11/Wayland), Windows, macOS, and Android (API level 29+).

Note: current_directory might be ignored.

Note: Embedded file dialogs and Windows file dialogs 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.

Note: On Android, this method uses the Android Storage Access Framework (SAF).

The file picker returns a URI instead of a filesystem path. This URI can be passed directly to FileAccess to perform read/write operations.

When using FileDialogMode::OPEN_DIR, it returns a tree URI that grants full access to the selected directory. File operations inside this directory can be performed by passing a path on the form treeUri#relative/path/to/file to FileAccess.

To avoid opening the file picker again after each app restart, you can take persistable URI permission as follows:

val uri = "content://com.android..." # URI of the selected file or folder.
val persist = true # Set to false to release the persistable permission.
var android_runtime = Engine.get_singleton("AndroidRuntime")
android_runtime.updatePersistableUriPermission(uri, persist)

The persistable URI permission remains valid across app restarts as long as the directory is not moved, renamed, or deleted.

pub fn file_dialog_with_options_show( &mut self, title: impl AsArg<GString>, current_directory: impl AsArg<GString>, root: impl AsArg<GString>, filename: impl AsArg<GString>, show_hidden: bool, mode: FileDialogMode, filters: &PackedArray<GString>, options: &Array<AnyDictionary>, callback: &Callable, ) -> Error

To set the default parameters, use file_dialog_with_options_show_ex and its builder methods. See the book for detailed usage instructions. 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 [member FileDialog.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 Feature::NATIVE_DIALOG_FILE_EXTRA feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.

Note: current_directory might be ignored.

Note: Embedded file dialogs and Windows file dialogs 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.

pub fn file_dialog_with_options_show_ex<'ex>( &'ex mut self, title: impl AsArg<GString> + 'ex, current_directory: impl AsArg<GString> + 'ex, root: impl AsArg<GString> + 'ex, filename: impl AsArg<GString> + 'ex, show_hidden: bool, mode: FileDialogMode, filters: &'ex PackedArray<GString>, options: &'ex Array<AnyDictionary>, callback: &'ex Callable, ) -> ExFileDialogWithOptionsShow<'ex>

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 [member FileDialog.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 Feature::NATIVE_DIALOG_FILE_EXTRA feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.

Note: current_directory might be ignored.

Note: Embedded file dialogs and Windows file dialogs 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.

pub fn beep(&self)

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.

pub fn keyboard_get_layout_count(&self) -> i32

Returns the number of keyboard layouts.

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

pub fn keyboard_get_current_layout(&self) -> i32

Returns active keyboard layout index.

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

pub fn keyboard_set_current_layout(&mut self, index: i32)

Sets the active keyboard layout.

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

pub fn keyboard_get_layout_language(&self, index: i32) -> GString

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.

pub fn keyboard_get_layout_name(&self, index: i32) -> GString

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

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

pub fn keyboard_get_keycode_from_physical(&self, keycode: Key) -> Key

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.

pub fn keyboard_get_label_from_physical(&self, keycode: Key) -> 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/Wayland), macOS and Windows.

pub fn show_emoji_and_symbol_picker(&self)

Opens system emoji and symbol picker.

Note: This method is implemented on macOS and Windows.

pub fn color_picker(&mut self, callback: &Callable) -> bool

Displays OS native color picker.

Callbacks have the following arguments: status: bool, color: Color.

Note: This method is implemented if the display server has the Feature::NATIVE_COLOR_PICKER feature.

Note: This method is only implemented on Linux (X11/Wayland).

pub fn process_events(&mut self)

Perform window manager processing, including input flushing. See also force_process_and_drop_events, flush_buffered_events and [member Input.use_accumulated_input].

pub fn force_process_and_drop_events(&mut self)

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

Note: This method is implemented on Windows and macOS.

pub fn set_native_icon(&mut self, filename: impl AsArg<GString>)

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

Note: Requires support for Feature::NATIVE_ICON.

pub fn set_icon(&mut self, image: impl AsArg<Option<Gd<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 set_native_icon instead.

Note: Requires support for Feature::ICON.

pub fn create_status_indicator( &mut self, icon: impl AsArg<Option<Gd<Texture2D>>>, tooltip: impl AsArg<GString>, callback: &Callable, ) -> i32

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 [enum MouseButton] constants) and the click position in screen coordinates (a Vector2i).

pub fn status_indicator_set_icon( &mut self, id: i32, icon: impl AsArg<Option<Gd<Texture2D>>>, )

Sets the application status indicator icon.

Note: This method is implemented on macOS and Windows.

pub fn status_indicator_set_tooltip( &mut self, id: i32, tooltip: impl AsArg<GString>, )

Sets the application status indicator tooltip.

Note: This method is implemented on macOS and Windows.

pub fn status_indicator_set_menu(&mut self, id: i32, menu_rid: 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 Feature::POPUP_MENU feature.

pub fn status_indicator_set_callback(&mut self, id: i32, callback: &Callable)

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

Note: This method is implemented on macOS and Windows.

pub fn status_indicator_get_rect(&self, id: i32) -> Rect2

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.

pub fn delete_status_indicator(&mut self, id: i32)

Removes the application status indicator.

pub fn tablet_get_driver_count(&self) -> i32

Returns the total number of available tablet drivers.

Note: This method is implemented only on Windows.

pub fn tablet_get_driver_name(&self, idx: i32) -> GString

Returns the tablet driver name for the given index.

Note: This method is implemented only on Windows.

pub fn tablet_get_current_driver(&self) -> GString

Returns current active tablet driver name.

Note: This method is implemented only on Windows.

pub fn tablet_set_current_driver(&mut self, name: impl AsArg<GString>)

Set active tablet driver name.

Supported drivers:

  • winink: Windows Ink API, default.

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

  • dummy: Dummy driver, tablet input is disabled.

Note: This method is implemented only on Windows.

pub fn is_window_transparency_available(&self) -> bool

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

pub fn register_additional_output( &mut self, object: impl AsArg<Option<Gd<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 unregister_additional_output.

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

pub fn unregister_additional_output( &mut self, object: impl AsArg<Option<Gd<Object>>>, )

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

pub fn has_additional_outputs(&self) -> bool

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

Methods from Deref<Target = Object>§

pub fn get_script(&self) -> Option<Gd<Script>>

pub fn set_script(&mut self, script: impl AsArg<Option<Gd<Script>>>)

pub fn connect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, ) -> Error

pub fn connect_flags( &mut self, signal: impl AsArg<StringName>, callable: &Callable, flags: ConnectFlags, ) -> Error

pub fn get_class(&self) -> GString

Returns the object’s built-in class name, as a String. See also is_class.

Note: This method ignores class_name declarations. If this object’s script has defined a class_name, the base, built-in class name is returned instead.

pub fn is_class(&self, class: impl AsArg<GString>) -> bool

Returns true if the object inherits from the given class. See also get_class.

var sprite2d = Sprite2D.new()
sprite2d.is_class("Sprite2D") # Returns true
sprite2d.is_class("Node")     # Returns true
sprite2d.is_class("Node3D")   # Returns false

Note: This method ignores class_name declarations in the object’s script.

pub fn set(&mut self, property: impl AsArg<StringName>, value: &Variant)

Assigns value to the given property. If the property does not exist or the given value’s type doesn’t match, nothing happens.

var node = Node2D.new()
node.set("global_scale", Vector2(8, 2.5))
print(node.global_scale) # Prints (8.0, 2.5)

Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.

pub fn get(&self, property: impl AsArg<StringName>) -> Variant

Returns the Variant value of the given property. If the property does not exist, this method returns null.

var node = Node2D.new()
node.rotation = 1.5
var a = node.get("rotation") # a is 1.5

Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.

pub fn set_indexed( &mut self, property_path: impl AsArg<NodePath>, value: &Variant, )

Assigns a new value to the property identified by the property_path. The path should be a NodePath relative to this object, and can use the colon character (:) to access nested properties.

var node = Node2D.new()
node.set_indexed("position", Vector2(42, 0))
node.set_indexed("position:y", -10)
print(node.position) # Prints (42.0, -10.0)

Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.

pub fn get_indexed(&self, property_path: impl AsArg<NodePath>) -> Variant

Gets the object’s property indexed by the given property_path. The path should be a NodePath relative to the current object and can use the colon character (:) to access nested properties.

Examples: "position:x" or "material:next_pass:blend_mode".

var node = Node2D.new()
node.position = Vector2(5, -10)
var a = node.get_indexed("position")   # a is Vector2(5, -10)
var b = node.get_indexed("position:y") # b is -10

Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.

Note: This method does not support actual paths to nodes in the SceneTree, only sub-property paths. In the context of nodes, use get_node_and_resource instead.

pub fn get_property_list(&self) -> Array<Dictionary<Variant, Variant>>

Returns the object’s property list as an Array of dictionaries. Each Dictionary contains the following entries:

  • name is the property’s name, as a String;

  • class_name is an empty StringName, unless the property is VariantType::OBJECT and it inherits from a class;

  • type is the property’s type, as an int (see [enum Variant.Type]);

  • hint is how the property is meant to be edited (see [enum PropertyHint]);

  • hint_string depends on the hint (see [enum PropertyHint]);

  • usage is a combination of [enum PropertyUsageFlags].

Note: In GDScript, all class members are treated as properties. In C# and GDExtension, it may be necessary to explicitly mark class members as Godot properties using decorators or attributes.

pub fn get_method_list(&self) -> Array<Dictionary<Variant, Variant>>

Returns this object’s methods and their signatures as an Array of dictionaries. Each Dictionary contains the following entries:

  • name is the name of the method, as a String;

  • args is an Array of dictionaries representing the arguments;

  • default_args is the default arguments as an Array of variants;

  • flags is a combination of [enum MethodFlags];

  • id is the method’s internal identifier int;

  • return is the returned value, as a Dictionary;

Note: The dictionaries of args and return are formatted identically to the results of get_property_list, although not all entries are used.

pub fn property_can_revert(&self, property: impl AsArg<StringName>) -> bool

Returns true if the given property has a custom default value. Use property_get_revert to get the property’s default value.

Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_can_revert] to customize the default value. If [method _property_can_revert] is not implemented, this method returns false.

pub fn property_get_revert(&self, property: impl AsArg<StringName>) -> Variant

Returns the custom default value of the given property. Use property_can_revert to check if the property has a custom default value.

Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_get_revert] to customize the default value. If [method _property_get_revert] is not implemented, this method returns null.

pub fn set_meta(&mut self, name: impl AsArg<StringName>, value: &Variant)

Adds or changes the entry name inside the object’s metadata. The metadata value can be any Variant, although some types cannot be serialized correctly.

If value is null, the entry is removed. This is the equivalent of using remove_meta. See also has_meta and get_meta.

Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.

Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.

pub fn remove_meta(&mut self, name: impl AsArg<StringName>)

Removes the given entry name from the object’s metadata. See also has_meta, get_meta and set_meta.

Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.

Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.

pub fn get_meta(&self, name: impl AsArg<StringName>) -> Variant

To set the default parameters, use get_meta_ex and its builder methods. See the book for detailed usage instructions. Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.

Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.

Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.

pub fn get_meta_ex<'ex>( &'ex self, name: impl AsArg<StringName> + 'ex, ) -> ExGetMeta<'ex>

Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.

Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.

Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.

pub fn has_meta(&self, name: impl AsArg<StringName>) -> bool

Returns true if a metadata entry is found with the given name. See also get_meta, set_meta and remove_meta.

Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.

Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.

pub fn get_meta_list(&self) -> Array<StringName>

Returns the object’s metadata entry names as an Array of StringNames.

pub fn add_user_signal(&mut self, signal: impl AsArg<GString>)

To set the default parameters, use add_user_signal_ex and its builder methods. See the book for detailed usage instructions. Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.

add_user_signal("hurt", [
	{ "name": "damage", "type": TYPE_INT },
	{ "name": "source", "type": TYPE_OBJECT }
])

pub fn add_user_signal_ex<'ex>( &'ex mut self, signal: impl AsArg<GString> + 'ex, ) -> ExAddUserSignal<'ex>

Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.

add_user_signal("hurt", [
	{ "name": "damage", "type": TYPE_INT },
	{ "name": "source", "type": TYPE_OBJECT }
])

pub fn has_user_signal(&self, signal: impl AsArg<StringName>) -> bool

Returns true if the given user-defined signal name exists. Only signals added with add_user_signal are included. See also remove_user_signal.

pub fn remove_user_signal(&mut self, signal: impl AsArg<StringName>)

Removes the given user signal signal from the object. See also add_user_signal and has_user_signal.

pub fn emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Error

Emits the given signal by name. The signal must exist, so it should be a built-in signal of this class or one of its inherited classes, or a user-defined signal (see add_user_signal). This method supports a variable number of arguments, so parameters can be passed as a comma separated list.

Returns Error::ERR_UNAVAILABLE if signal does not exist or the parameters are invalid.

emit_signal("hit", "sword", 100)
emit_signal("game_over")

Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.

§Panics

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will panic in such a case.

pub fn try_emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Error, CallError>

§Return type

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will return Err in such a case.

pub fn call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant

Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters can be passed as a comma separated list.

var node = Node3D.new()
node.call("rotate", Vector3(1.0, 0.0, 0.0), 1.571)

Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.

§Panics

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will panic in such a case.

pub fn try_call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>

§Return type

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will return Err in such a case.

pub fn call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant

Calls the method on the object during idle time. Always returns null, not the method’s result.

Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they’ll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.

This method supports a variable number of arguments, so parameters can be passed as a comma separated list.

var node = Node3D.new()
node.call_deferred("rotate", Vector3(1.0, 0.0, 0.0), 1.571)

For methods that are deferred from the same thread, the order of execution at idle time is identical to the order in which call_deferred was called.

See also call_deferred.

Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.

Note: If you’re looking to delay the function call by a frame, refer to the SceneTree.process_frame and SceneTree.physics_frame signals.

var node = Node3D.new()
# Make a Callable and bind the arguments to the node's rotate() call.
var callable = node.rotate.bind(Vector3(1.0, 0.0, 0.0), 1.571)
# Connect the callable to the process_frame signal, so it gets called in the next process frame.
# CONNECT_ONE_SHOT makes sure it only gets called once instead of every frame.
get_tree().process_frame.connect(callable, CONNECT_ONE_SHOT)
§Panics

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will panic in such a case.

pub fn try_call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>

§Return type

This is a varcall method, meaning parameters and return values are passed as Variant. It can detect call failures and will return Err in such a case.

pub fn set_deferred( &mut self, property: impl AsArg<StringName>, value: &Variant, )

Assigns value to the given property, at the end of the current frame. This is equivalent to calling set through call_deferred.

var node = Node2D.new()
add_child(node)

node.rotation = 1.5
node.set_deferred("rotation", 3.0)
print(node.rotation) # Prints 1.5

await get_tree().process_frame
print(node.rotation) # Prints 3.0

Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.

pub fn callv( &mut self, method: impl AsArg<StringName>, arg_array: &AnyArray, ) -> Variant

Calls the method on the object and returns the result. Unlike call, this method expects all parameters to be contained inside arg_array.

var node = Node3D.new()
node.callv("rotate", [Vector3(1.0, 0.0, 0.0), 1.571])

Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.

pub fn has_method(&self, method: impl AsArg<StringName>) -> bool

Returns true if the given method name exists in the object.

Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.

pub fn get_method_argument_count(&self, method: impl AsArg<StringName>) -> i32

Returns the number of arguments of the given method by name.

Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.

pub fn has_signal(&self, signal: impl AsArg<StringName>) -> bool

Returns true if the given signal name exists in the object.

Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.

pub fn get_signal_list(&self) -> Array<Dictionary<Variant, Variant>>

Returns the list of existing signals as an Array of dictionaries.

Note: Due to the implementation, each Dictionary is formatted very similarly to the returned values of get_method_list.

pub fn get_signal_connection_list( &self, signal: impl AsArg<StringName>, ) -> Array<Dictionary<Variant, Variant>>

Returns an Array of connections for the given signal name. Each connection is represented as a Dictionary that contains three entries:

  • signal is a reference to the Signal;

  • callable is a reference to the connected Callable;

  • flags is a combination of [enum ConnectFlags].

pub fn get_incoming_connections(&self) -> Array<Dictionary<Variant, Variant>>

Returns an Array of signal connections received by this object. Each connection is represented as a Dictionary that contains three entries:

  • signal is a reference to the Signal;

  • callable is a reference to the Callable;

  • flags is a combination of [enum ConnectFlags].

pub fn disconnect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, )

Disconnects a signal by name from a given callable. If the connection does not exist, generates an error. Use is_connected to make sure that the connection exists.

pub fn is_connected( &self, signal: impl AsArg<StringName>, callable: &Callable, ) -> bool

Returns true if a connection exists between the given signal name and callable.

Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.

pub fn has_connections(&self, signal: impl AsArg<StringName>) -> bool

Returns true if any connection exists on the given signal name.

Note: In C#, signal must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.

pub fn set_block_signals(&mut self, enable: bool)

If set to true, the object becomes unable to emit signals. As such, emit_signal and signal connections will not work, until it is set to false.

pub fn is_blocking_signals(&self) -> bool

Returns true if the object is blocking its signals from being emitted. See set_block_signals.

pub fn notify_property_list_changed(&mut self)

Emits the property_list_changed signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.

pub fn set_message_translation(&mut self, enable: bool)

If set to true, allows the object to translate messages with tr and tr_n. Enabled by default. See also can_translate_messages.

pub fn can_translate_messages(&self) -> bool

Returns true if the object is allowed to translate messages with tr and tr_n. See also set_message_translation.

pub fn tr(&self, message: impl AsArg<StringName>) -> GString

To set the default parameters, use tr_ex and its builder methods. See the book for detailed usage instructions. Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.

If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.

For detailed examples, see Internationalizing games.

Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.

pub fn tr_ex<'ex>(&'ex self, message: impl AsArg<StringName> + 'ex) -> ExTr<'ex>

Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.

If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.

For detailed examples, see Internationalizing games.

Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.

pub fn tr_n( &self, message: impl AsArg<StringName>, plural_message: impl AsArg<StringName>, n: i32, ) -> GString

To set the default parameters, use tr_n_ex and its builder methods. See the book for detailed usage instructions. Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.

If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.

The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.

For detailed examples, see Localization using gettext.

Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.

Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.

pub fn tr_n_ex<'ex>( &'ex self, message: impl AsArg<StringName> + 'ex, plural_message: impl AsArg<StringName> + 'ex, n: i32, ) -> ExTrN<'ex>

Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.

If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.

The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.

For detailed examples, see Localization using gettext.

Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.

Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.

pub fn get_translation_domain(&self) -> StringName

Returns the name of the translation domain used by tr and tr_n. See also TranslationServer.

pub fn set_translation_domain(&mut self, domain: impl AsArg<StringName>)

Sets the name of the translation domain used by tr and tr_n. See also TranslationServer.

pub fn is_queued_for_deletion(&self) -> bool

Returns true if the queue_free method was called for the object.

pub fn cancel_free(&mut self)

If this method is called during ObjectNotification::PREDELETE, this object will reject being freed and will remain allocated. This is mostly an internal function used for error handling to avoid the user from freeing objects when they are not intended to.

pub fn notify(&mut self, what: ObjectNotification)

⚠️ Sends a Godot notification to all classes inherited by the object.

Triggers calls to on_notification(), and depending on the notification, also to Godot’s lifecycle callbacks such as ready().

Starts from the highest ancestor (the Object class) and goes down the hierarchy. See also Godot docs for Object::notification().

§Panics

If you call this method on a user-defined object while holding a GdRef or GdMut guard on the instance, you will encounter a panic. The reason is that the receiving virtual method on_notification() acquires a GdMut lock dynamically, which must be exclusive.

pub fn notify_reversed(&mut self, what: ObjectNotification)

⚠️ Like Self::notify(), but starts at the most-derived class and goes up the hierarchy.

See docs of that method, including the panics.

Trait Implementations§

§

impl Bounds for DisplayServer

§

type Memory = MemManual

Defines the memory strategy of the static type.
§

type Declarer = DeclEngine

Whether this class is a core Godot class provided by the engine, or declared by the user as a Rust struct.
§

impl Debug for DisplayServer

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Deref for DisplayServer

§

type Target = Object

The resulting type after dereferencing.
§

fn deref(&self) -> &<DisplayServer as Deref>::Target

Dereferences the value.
§

impl DerefMut for DisplayServer

§

fn deref_mut(&mut self) -> &mut <DisplayServer as Deref>::Target

Mutably dereferences the value.
§

impl GodotClass for DisplayServer

§

const INIT_LEVEL: InitLevel = crate::init::InitLevel::Servers

Initialization level, during which this class should be initialized with Godot. Read more
§

type Base = Object

The immediate superclass of T. This is always a Godot engine class.
§

fn class_id() -> ClassId

Globally unique class ID, linked to the name under which the class is registered in Godot. Read more
§

fn inherits<Base>() -> bool
where Base: GodotClass,

Returns whether Self inherits from Base. Read more
§

impl Inherits<Object> for DisplayServer

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
§

impl Singleton for DisplayServer

§

fn singleton() -> Gd<DisplayServer>

Returns the singleton instance. Read more
§

impl WithSignals for DisplayServer

§

type SignalCollection<'c, C: WithSignals> = SignalsOfObject<'c, C>

The associated struct listing all signals of this class. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T
where T: GodotClass,

§

const IS_SAME_CLASS: bool = true

True iff Self == Base. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> UniformObjectDeref<DeclEngine> for T
where T: GodotClass<Declarer = DeclEngine>,

§

type TargetRef<'a> = Gd<T>

§

type TargetMut<'a> = Gd<T>

§

fn object_as_ref<'a>( gd: &'a Gd<T>, ) -> <T as UniformObjectDeref<DeclEngine>>::TargetRef<'a>

§

fn object_as_mut<'a>( gd: &'a mut Gd<T>, ) -> <T as UniformObjectDeref<DeclEngine>>::TargetMut<'a>