Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
DisplayServer
繼承: Object
用於低階視窗管理的伺服器介面。
說明
所有與視窗管理相關的內容都由 DisplayServer(顯示伺服器)處理。因為一個操作系統可能支援多個顯示伺服器,所以與 OS 是分開的。
無頭模式:如果使用 --headless 命令列參數啟動引擎,就會禁用所有算繪和視窗管理功能。此時 DisplayServer 的大多數函式都會返回虛擬值。
方法
訊號
orientation_changed(orientation: int) 🔗
Emitted when the device orientation changes. orientation is the new orientation.
Returns 1 for portrait, 2 for landscape, and 0 if the orientation is undefined.
Note: This method is implemented on Android and iOS.
列舉
enum Feature: 🔗
已棄用: Use NativeMenu or PopupMenu instead.
顯示伺服器支援全域功能表。能夠讓套用程式在作業系統的頂部欄顯示其功能表專案。macOS
Feature FEATURE_SUBWINDOWS = 1
顯示伺服器支援多視窗,可以移動到主視窗之外。Windows、macOS、Linux(X11)
Feature FEATURE_TOUCHSCREEN = 2
Display server supports touchscreen input. Windows, Linux (X11/Wayland), Android, iOS, Web
Feature FEATURE_MOUSE = 3
Display server supports mouse input. Windows, macOS, Linux (X11/Wayland), Android, Web
Feature FEATURE_MOUSE_WARP = 4
Display server supports warping mouse coordinates to keep the mouse cursor constrained within an area, but looping when one of the edges is reached. Windows, macOS, Linux (X11/Wayland)
Feature FEATURE_CLIPBOARD = 5
Display server supports setting and getting clipboard data. See also FEATURE_CLIPBOARD_PRIMARY. Windows, macOS, Linux (X11/Wayland), Android, iOS, Web
Feature FEATURE_VIRTUAL_KEYBOARD = 6
顯示伺服器支援在請求輸入文字但沒有物理鍵盤時彈出虛擬鍵盤。Android、iOS、Web
Feature FEATURE_CURSOR_SHAPE = 7
Display server supports setting the mouse cursor shape to be different from the default. Windows, macOS, Linux (X11/Wayland), Android, Web
Feature FEATURE_CUSTOM_CURSOR_SHAPE = 8
Display server supports setting the mouse cursor shape to a custom image. Windows, macOS, Linux (X11/Wayland), Web
Feature FEATURE_NATIVE_DIALOG = 9
Display server supports spawning text dialogs using the operating system's native look-and-feel. See dialog_show(). Windows, macOS
Feature FEATURE_IME = 10
顯示伺服器支援 輸入法,它通常用於輸入中文、日文和韓文文字。這由作業系統處理,而不是由 Godot 處理。Windows, macOS, Linux (X11)
Feature FEATURE_WINDOW_TRANSPARENCY = 11
Display server supports windows can use per-pixel transparency to make windows behind them partially or fully visible. Windows, macOS, Linux (X11/Wayland), Android
Feature FEATURE_HIDPI = 12
Display server supports querying the operating system's display scale factor. This allows automatically detecting the hiDPI display reliably, instead of guessing based on the screen resolution and the display's reported DPI (which might be unreliable due to broken monitor EDID). Windows, Linux (Wayland), macOS
Feature FEATURE_ICON = 13
Display server supports changing the window icon (usually displayed in the top-left corner). Windows, macOS, Linux (X11/Wayland)
Note: Use on Wayland requires the compositor to implement the xdg_toplevel_icon_v1 protocol, which not all compositors do. See xdg_toplevel_icon_v1#compositor-support for more information on individual compositor support.
Feature FEATURE_NATIVE_ICON = 14
顯示伺服器支援改變視窗圖示(通常顯示在左上角)。Windows、macOS
Feature FEATURE_ORIENTATION = 15
顯示伺服器支援改變螢幕朝向。Android、iOS
Feature FEATURE_SWAP_BUFFERS = 16
Display server supports V-Sync status can be changed from the default (which is forced to be enabled platforms not supporting this feature). Windows, macOS, Linux (X11/Wayland)
Feature FEATURE_CLIPBOARD_PRIMARY = 18
Display server supports Primary clipboard can be used. This is a different clipboard from FEATURE_CLIPBOARD. Linux (X11/Wayland)
Feature FEATURE_TEXT_TO_SPEECH = 19
Display server supports text-to-speech. See tts_* methods. Windows, macOS, Linux (X11/Wayland), Android, iOS, Web
Feature FEATURE_EXTEND_TO_TITLE = 20
顯示伺服器支援將視窗內容擴充到標題。見 WINDOW_FLAG_EXTEND_TO_TITLE。macOS
Feature FEATURE_SCREEN_CAPTURE = 21
顯示伺服器支援讀取螢幕圖元。見 screen_get_pixel()。
Feature FEATURE_STATUS_INDICATOR = 22
Display server supports application status indicators.
Feature FEATURE_NATIVE_HELP = 23
Display server supports native help system search callbacks. See help_set_search_callbacks().
Feature FEATURE_NATIVE_DIALOG_INPUT = 24
Display server supports spawning text input dialogs using the operating system's native look-and-feel. See dialog_input_text(). Windows, macOS
Feature FEATURE_NATIVE_DIALOG_FILE = 25
Display server supports spawning dialogs for selecting files or directories using the operating system's native look-and-feel. See file_dialog_show(). Windows, macOS, Linux (X11/Wayland), Android
Feature FEATURE_NATIVE_DIALOG_FILE_EXTRA = 26
The display server supports all features of FEATURE_NATIVE_DIALOG_FILE, with the added functionality of Options and native dialog file access to res:// and user:// paths. See file_dialog_show() and file_dialog_with_options_show(). Windows, macOS, Linux (X11/Wayland)
Feature FEATURE_WINDOW_DRAG = 27
The display server supports initiating window drag and resize operations on demand. See window_start_drag() and window_start_resize().
Feature FEATURE_SCREEN_EXCLUDE_FROM_CAPTURE = 28
Display server supports WINDOW_FLAG_EXCLUDE_FROM_CAPTURE window flag. Windows, macOS
Feature FEATURE_WINDOW_EMBEDDING = 29
Display server supports embedding a window from another process. Windows, Linux (X11), macOS
Feature FEATURE_NATIVE_DIALOG_FILE_MIME = 30
Native file selection dialog supports MIME types as filters.
Feature FEATURE_EMOJI_AND_SYMBOL_PICKER = 31
Display server supports system emoji and symbol picker. Windows, macOS
Feature FEATURE_NATIVE_COLOR_PICKER = 32
Display server supports native color picker. Linux (X11/Wayland)
Feature FEATURE_SELF_FITTING_WINDOWS = 33
Display server automatically fits popups according to the screen boundaries. Window nodes should not attempt to do that themselves.
Feature FEATURE_ACCESSIBILITY_SCREEN_READER = 34
Display server supports interaction with screen reader or Braille display. Linux (X11/Wayland), macOS, Windows
Feature FEATURE_HDR_OUTPUT = 35
Display server supports HDR output. Linux (Wayland), macOS, iOS, visionOS, Windows
Feature FEATURE_PIP_MODE = 36
Display server supports putting the application in picture-in-picture mode. Android
enum AccessibilityRole: 🔗
AccessibilityRole ROLE_UNKNOWN = 0
已棄用: Use AccessibilityServer instead.
Unknown or custom role.
AccessibilityRole ROLE_DEFAULT_BUTTON = 1
已棄用: Use AccessibilityServer instead.
Default dialog button element.
AccessibilityRole ROLE_AUDIO = 2
已棄用: Use AccessibilityServer instead.
Audio player element.
AccessibilityRole ROLE_VIDEO = 3
已棄用: Use AccessibilityServer instead.
Video player element.
AccessibilityRole ROLE_STATIC_TEXT = 4
已棄用: Use AccessibilityServer instead.
Non-editable text label.
AccessibilityRole ROLE_CONTAINER = 5
已棄用: Use AccessibilityServer instead.
Container element. Elements with this role are used for internal structure and ignored by screen readers.
AccessibilityRole ROLE_PANEL = 6
已棄用: Use AccessibilityServer instead.
Panel container element.
AccessibilityRole ROLE_BUTTON = 7
已棄用: Use AccessibilityServer instead.
Button element.
AccessibilityRole ROLE_LINK = 8
已棄用: Use AccessibilityServer instead.
Link element.
AccessibilityRole ROLE_CHECK_BOX = 9
已棄用: Use AccessibilityServer instead.
Check box element.
AccessibilityRole ROLE_RADIO_BUTTON = 10
已棄用: Use AccessibilityServer instead.
Radio button element.
AccessibilityRole ROLE_CHECK_BUTTON = 11
已棄用: Use AccessibilityServer instead.
Check button element.
AccessibilityRole ROLE_SCROLL_BAR = 12
已棄用: Use AccessibilityServer instead.
Scroll bar element.
AccessibilityRole ROLE_SCROLL_VIEW = 13
已棄用: Use AccessibilityServer instead.
Scroll container element.
AccessibilityRole ROLE_SPLITTER = 14
已棄用: Use AccessibilityServer instead.
Container splitter handle element.
AccessibilityRole ROLE_SLIDER = 15
已棄用: Use AccessibilityServer instead.
Slider element.
AccessibilityRole ROLE_SPIN_BUTTON = 16
已棄用: Use AccessibilityServer instead.
Spin box element.
AccessibilityRole ROLE_PROGRESS_INDICATOR = 17
已棄用: Use AccessibilityServer instead.
Progress indicator element.
AccessibilityRole ROLE_TEXT_FIELD = 18
已棄用: Use AccessibilityServer instead.
Editable text field element.
AccessibilityRole ROLE_MULTILINE_TEXT_FIELD = 19
已棄用: Use AccessibilityServer instead.
Multiline editable text field element.
AccessibilityRole ROLE_COLOR_PICKER = 20
已棄用: Use AccessibilityServer instead.
Color picker element.
AccessibilityRole ROLE_TABLE = 21
已棄用: Use AccessibilityServer instead.
Table element.
AccessibilityRole ROLE_CELL = 22
已棄用: Use AccessibilityServer instead.
Table/tree cell element.
AccessibilityRole ROLE_ROW = 23
已棄用: Use AccessibilityServer instead.
Table/tree row element.
AccessibilityRole ROLE_ROW_GROUP = 24
已棄用: Use AccessibilityServer instead.
Table/tree row group element.
AccessibilityRole ROLE_ROW_HEADER = 25
已棄用: Use AccessibilityServer instead.
Table/tree row header element.
AccessibilityRole ROLE_COLUMN_HEADER = 26
已棄用: Use AccessibilityServer instead.
Table/tree column header element.
AccessibilityRole ROLE_TREE = 27
已棄用: Use AccessibilityServer instead.
Tree view element.
AccessibilityRole ROLE_TREE_ITEM = 28
已棄用: Use AccessibilityServer instead.
Tree view item element.
AccessibilityRole ROLE_LIST = 29
已棄用: Use AccessibilityServer instead.
List element.
AccessibilityRole ROLE_LIST_ITEM = 30
已棄用: Use AccessibilityServer instead.
List item element.
AccessibilityRole ROLE_LIST_BOX = 31
已棄用: Use AccessibilityServer instead.
List view element.
AccessibilityRole ROLE_LIST_BOX_OPTION = 32
已棄用: Use AccessibilityServer instead.
List view item element.
AccessibilityRole ROLE_TAB_BAR = 33
已棄用: Use AccessibilityServer instead.
Tab bar element.
AccessibilityRole ROLE_TAB = 34
已棄用: Use AccessibilityServer instead.
Tab bar item element.
AccessibilityRole ROLE_TAB_PANEL = 35
已棄用: Use AccessibilityServer instead.
Tab panel element.
已棄用: Use AccessibilityServer instead.
Menu bar element.
已棄用: Use AccessibilityServer instead.
Popup menu element.
已棄用: Use AccessibilityServer instead.
Popup menu item element.
已棄用: Use AccessibilityServer instead.
Popup menu check button item element.
已棄用: Use AccessibilityServer instead.
Popup menu radio button item element.
AccessibilityRole ROLE_IMAGE = 41
已棄用: Use AccessibilityServer instead.
Image element.
AccessibilityRole ROLE_WINDOW = 42
已棄用: Use AccessibilityServer instead.
Window element.
AccessibilityRole ROLE_TITLE_BAR = 43
已棄用: Use AccessibilityServer instead.
Embedded window title bar element.
AccessibilityRole ROLE_DIALOG = 44
已棄用: Use AccessibilityServer instead.
Dialog window element.
AccessibilityRole ROLE_TOOLTIP = 45
已棄用: Use AccessibilityServer instead.
Tooltip element.
AccessibilityRole ROLE_REGION = 46
已棄用: Use AccessibilityServer instead.
Region/landmark element. Screen readers can navigate between regions using landmark navigation.
AccessibilityRole ROLE_TEXT_RUN = 47
已棄用: Use AccessibilityServer instead.
Unifor text run.
Note: This role is used for internal text elements, and should not be assigned to nodes.
enum AccessibilityPopupType: 🔗
已棄用: Use AccessibilityServer instead.
Popup menu.
AccessibilityPopupType POPUP_LIST = 1
已棄用: Use AccessibilityServer instead.
Popup list.
AccessibilityPopupType POPUP_TREE = 2
已棄用: Use AccessibilityServer instead.
Popup tree view.
AccessibilityPopupType POPUP_DIALOG = 3
已棄用: Use AccessibilityServer instead.
Popup dialog.
enum AccessibilityFlags: 🔗
已棄用: Use AccessibilityServer instead.
Element is hidden for accessibility tools.
AccessibilityFlags FLAG_MULTISELECTABLE = 1
已棄用: Use AccessibilityServer instead.
Element supports multiple item selection.
AccessibilityFlags FLAG_REQUIRED = 2
已棄用: Use AccessibilityServer instead.
Element require user input.
AccessibilityFlags FLAG_VISITED = 3
已棄用: Use AccessibilityServer instead.
Element is a visited link.
AccessibilityFlags FLAG_BUSY = 4
已棄用: Use AccessibilityServer instead.
Element content is not ready (e.g. loading).
AccessibilityFlags FLAG_MODAL = 5
已棄用: Use AccessibilityServer instead.
Element is modal window.
AccessibilityFlags FLAG_TOUCH_PASSTHROUGH = 6
已棄用: Use AccessibilityServer instead.
Element allows touches to be passed through when a screen reader is in touch exploration mode.
AccessibilityFlags FLAG_READONLY = 7
已棄用: Use AccessibilityServer instead.
Element is text field with selectable but read-only text.
AccessibilityFlags FLAG_DISABLED = 8
已棄用: Use AccessibilityServer instead.
Element is disabled.
AccessibilityFlags FLAG_CLIPS_CHILDREN = 9
已棄用: Use AccessibilityServer instead.
Element clips children.
enum AccessibilityAction: 🔗
AccessibilityAction ACTION_CLICK = 0
已棄用: Use AccessibilityServer instead.
Single click action, callback argument is not set.
AccessibilityAction ACTION_FOCUS = 1
已棄用: Use AccessibilityServer instead.
Focus action, callback argument is not set.
AccessibilityAction ACTION_BLUR = 2
已棄用: Use AccessibilityServer instead.
Blur action, callback argument is not set.
AccessibilityAction ACTION_COLLAPSE = 3
已棄用: Use AccessibilityServer instead.
Collapse action, callback argument is not set.
AccessibilityAction ACTION_EXPAND = 4
已棄用: Use AccessibilityServer instead.
Expand action, callback argument is not set.
AccessibilityAction ACTION_DECREMENT = 5
已棄用: Use AccessibilityServer instead.
Decrement action, callback argument is not set.
AccessibilityAction ACTION_INCREMENT = 6
已棄用: Use AccessibilityServer instead.
Increment action, callback argument is not set.
AccessibilityAction ACTION_HIDE_TOOLTIP = 7
已棄用: Use AccessibilityServer instead.
Hide tooltip action, callback argument is not set.
AccessibilityAction ACTION_SHOW_TOOLTIP = 8
已棄用: Use AccessibilityServer instead.
Show tooltip action, callback argument is not set.
AccessibilityAction ACTION_SET_TEXT_SELECTION = 9
已棄用: Use AccessibilityServer instead.
Set text selection action, callback argument is set to Dictionary with the following keys:
"start_element"accessibility element of the selection start."start_char"character offset relative to the accessibility element of the selection start."end_element"accessibility element of the selection end."end_char"character offset relative to the accessibility element of the selection end.
AccessibilityAction ACTION_REPLACE_SELECTED_TEXT = 10
已棄用: Use AccessibilityServer instead.
Replace text action, callback argument is set to String with the replacement text.
AccessibilityAction ACTION_SCROLL_BACKWARD = 11
已棄用: Use AccessibilityServer instead.
Scroll backward action, callback argument is not set.
AccessibilityAction ACTION_SCROLL_DOWN = 12
已棄用: Use AccessibilityServer instead.
Scroll down action, callback argument is set to AccessibilityScrollUnit.
AccessibilityAction ACTION_SCROLL_FORWARD = 13
已棄用: Use AccessibilityServer instead.
Scroll forward action, callback argument is not set.
AccessibilityAction ACTION_SCROLL_LEFT = 14
已棄用: Use AccessibilityServer instead.
Scroll left action, callback argument is set to AccessibilityScrollUnit.
AccessibilityAction ACTION_SCROLL_RIGHT = 15
已棄用: Use AccessibilityServer instead.
Scroll right action, callback argument is set to AccessibilityScrollUnit.
AccessibilityAction ACTION_SCROLL_UP = 16
已棄用: Use AccessibilityServer instead.
Scroll up action, callback argument is set to AccessibilityScrollUnit.
AccessibilityAction ACTION_SCROLL_INTO_VIEW = 17
已棄用: Use AccessibilityServer instead.
Scroll into view action, callback argument is set to AccessibilityScrollHint.
AccessibilityAction ACTION_SCROLL_TO_POINT = 18
已棄用: Use AccessibilityServer instead.
Scroll to point action, callback argument is set to Vector2 with the relative point coordinates.
AccessibilityAction ACTION_SET_SCROLL_OFFSET = 19
已棄用: Use AccessibilityServer instead.
Set scroll offset action, callback argument is set to Vector2 with the scroll offset.
AccessibilityAction ACTION_SET_VALUE = 20
已棄用: Use AccessibilityServer instead.
Set value action, callback argument is set to String or number with the new value.
已棄用: Use AccessibilityServer instead.
Show context menu action, callback argument is not set.
AccessibilityAction ACTION_CUSTOM = 22
已棄用: Use AccessibilityServer instead.
Custom action, callback argument is set to the integer action ID.
enum AccessibilityLiveMode: 🔗
AccessibilityLiveMode LIVE_OFF = 0
已棄用: Use AccessibilityServer instead.
Indicates that updates to the live region should not be presented.
AccessibilityLiveMode LIVE_POLITE = 1
已棄用: Use AccessibilityServer instead.
Indicates that updates to the live region should be presented at the next opportunity (for example at the end of speaking the current sentence).
AccessibilityLiveMode LIVE_ASSERTIVE = 2
已棄用: Use AccessibilityServer instead.
Indicates that updates to the live region have the highest priority and should be presented immediately.
enum AccessibilityScrollUnit: 🔗
AccessibilityScrollUnit SCROLL_UNIT_ITEM = 0
已棄用: Use AccessibilityServer instead.
The amount by which to scroll. A single item of a list, line of text.
AccessibilityScrollUnit SCROLL_UNIT_PAGE = 1
已棄用: Use AccessibilityServer instead.
The amount by which to scroll. A single page.
enum AccessibilityScrollHint: 🔗
AccessibilityScrollHint SCROLL_HINT_TOP_LEFT = 0
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Top-left edge of the scroll container.
AccessibilityScrollHint SCROLL_HINT_BOTTOM_RIGHT = 1
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Bottom-right edge of the scroll container.
AccessibilityScrollHint SCROLL_HINT_TOP_EDGE = 2
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Top edge of the scroll container.
AccessibilityScrollHint SCROLL_HINT_BOTTOM_EDGE = 3
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Bottom edge of the scroll container.
AccessibilityScrollHint SCROLL_HINT_LEFT_EDGE = 4
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Left edge of the scroll container.
AccessibilityScrollHint SCROLL_HINT_RIGHT_EDGE = 5
已棄用: Use AccessibilityServer instead.
A preferred position for the node scrolled into view. Right edge of the scroll container.
enum MouseMode: 🔗
MouseMode MOUSE_MODE_VISIBLE = 0
如果滑鼠游標處於隱藏狀態,則使其可見。
如果滑鼠游標是可見的,則使其隱藏。
MouseMode MOUSE_MODE_CAPTURED = 2
捕獲滑鼠。滑鼠將被隱藏,其位置被鎖定在視窗管理器視窗的中心。
注意:如果你想在這種模式下處理滑鼠的移動,則需要使用 InputEventMouseMotion.relative。
MouseMode MOUSE_MODE_CONFINED = 3
將滑鼠游標限制在遊戲視窗內,並使其可見。
將滑鼠游標限制在遊戲視窗內,並使其隱藏。
MouseMode MOUSE_MODE_MAX = 5
Max value of the MouseMode.
enum ScreenOrientation: 🔗
ScreenOrientation SCREEN_LANDSCAPE = 0
預設橫屏朝向。
ScreenOrientation SCREEN_PORTRAIT = 1
預設豎屏朝向。
ScreenOrientation SCREEN_REVERSE_LANDSCAPE = 2
倒橫屏朝向(上下顛倒)。
ScreenOrientation SCREEN_REVERSE_PORTRAIT = 3
倒豎屏朝向(上下顛倒)。
ScreenOrientation SCREEN_SENSOR_LANDSCAPE = 4
自動橫屏朝向(感測器決定預設或倒向)。
ScreenOrientation SCREEN_SENSOR_PORTRAIT = 5
自動豎屏朝向(感測器決定預設或倒向)。
ScreenOrientation SCREEN_SENSOR = 6
自動橫屏或豎屏朝向(感測器決定預設或倒向)。
enum VirtualKeyboardType: 🔗
VirtualKeyboardType KEYBOARD_TYPE_DEFAULT = 0
預設文字虛擬鍵盤。
VirtualKeyboardType KEYBOARD_TYPE_MULTILINE = 1
多行虛擬鍵盤。
VirtualKeyboardType KEYBOARD_TYPE_NUMBER = 2
虛擬數位鍵盤,可用於 PIN 輸入。
VirtualKeyboardType KEYBOARD_TYPE_NUMBER_DECIMAL = 3
虛擬數位鍵盤,可用於輸入小數。
VirtualKeyboardType KEYBOARD_TYPE_PHONE = 4
虛擬手機號碼鍵盤。
VirtualKeyboardType KEYBOARD_TYPE_EMAIL_ADDRESS = 5
帶有附加鍵的虛擬鍵盤,可説明輸入電子郵寄地址。
VirtualKeyboardType KEYBOARD_TYPE_PASSWORD = 6
用於輸入密碼的虛擬鍵盤。在大多數平臺上,這應該會禁用自動完成和自動首字母大寫功能。
注意:Web 平臺不支援。與 KEYBOARD_TYPE_DEFAULT 的行為相同。
VirtualKeyboardType KEYBOARD_TYPE_URL = 7
帶有附加鍵的虛擬鍵盤,可説明輸入 URL。
enum CursorShape: 🔗
CursorShape CURSOR_ARROW = 0
箭頭游標形狀。這是預設形狀,沒有指向 LineEdit 和 TextEdit 等會覆蓋滑鼠指針的節點時顯示。
CursorShape CURSOR_IBEAM = 1
工字游標形狀。預設在懸停於 LineEdit 和 TextEdit 等接受文字輸入的控制項時顯示。
CursorShape CURSOR_POINTING_HAND = 2
指點的手形游標形狀。預設在懸停於 LinkButton 或 RichTextLabel 中的 URL 標簽時使用。
CursorShape CURSOR_CROSS = 3
十字游標。應當在使用者需要精確瞄準某個元素時顯示,例如矩形選擇工具和顏色拾取器。
CursorShape CURSOR_WAIT = 4
等待游標。大多數游標主題會在箭頭旁邊顯示旋轉圖示。旨在用於非阻塞操作(此時使用者可以做其他事情)。另見 CURSOR_BUSY。
CursorShape CURSOR_BUSY = 5
等待游標。大多數游標主題會把箭頭替換為旋轉圖示。旨在用於阻塞操作(此時使用者無法做其他事情)。另見 CURSOR_WAIT。
CursorShape CURSOR_DRAG = 6
拖動的手形游標。在拖放操作過程中顯示。另見 CURSOR_CAN_DROP。
CursorShape CURSOR_CAN_DROP = 7
“能放下”游標。在拖放操作過程中,如果將滑鼠懸停在可以接受拖放事件的 Control 上,就會顯示這個游標。大多數游標主題會顯示一隻正在拖拽的手,旁邊有一個箭頭符號。另見 CURSOR_DRAG。
CursorShape CURSOR_FORBIDDEN = 8
禁止游標。在拖放操作過程中,如果將滑鼠懸停在不可接受拖放事件的 Control 上,就會顯示這個游標。
CursorShape CURSOR_VSIZE = 9
垂直尺寸調整游標。只在用於懸停的 Control 可以用滑鼠調整垂直大小時顯示。另見 CURSOR_VSPLIT。
CursorShape CURSOR_HSIZE = 10
水平尺寸調整游標。只在用於懸停的 Control 可以用滑鼠調整水平大小時顯示。另見 CURSOR_HSPLIT。
CursorShape CURSOR_BDIAGSIZE = 11
輔助對角線尺寸調整游標(右上/左下)。只在但懸停的 Control 可以使用滑鼠同時在兩個軸上調整大小時顯示。
CursorShape CURSOR_FDIAGSIZE = 12
主對角線尺寸調整游標(左上/右下)。只在當懸停的 Control 可以使用滑鼠同時在兩個軸上調整大小時顯示。
CursorShape CURSOR_MOVE = 13
移動游標。應在能夠使用滑鼠移動被懸停 Control 時顯示。
CursorShape CURSOR_VSPLIT = 14
垂直分割游標。當游標懸停於 VSplitContainer 等能夠使用滑鼠調整拆分的垂直大小的 Control 時顯示。部分游標主題中,該游標的外觀和 CURSOR_VSIZE 一致。
CursorShape CURSOR_HSPLIT = 15
水平分割游標。當游標懸停於 HSplitContainer 等能夠使用滑鼠調整拆分的水平大小的 Control 時顯示。部分游標主題中,該游標的外觀和 CURSOR_HSIZE 一致。
CursorShape CURSOR_HELP = 16
幫助游標。在大多數游標主題中顯示為問號圖示,不顯示為滑鼠游標。應在使用者請求對下一次點擊的元素提供説明資訊時使用。
CursorShape CURSOR_MAX = 17
代表 CursorShape 列舉的大小。
enum FileDialogMode: 🔗
FileDialogMode FILE_DIALOG_MODE_OPEN_FILE = 0
該對話方塊只允許選擇一個檔。
FileDialogMode FILE_DIALOG_MODE_OPEN_FILES = 1
該對話方塊允許選擇多個檔。
FileDialogMode FILE_DIALOG_MODE_OPEN_DIR = 2
該對話方塊只允許選擇一個目錄,不允許選擇任何檔。
FileDialogMode FILE_DIALOG_MODE_OPEN_ANY = 3
該對話方塊允許選擇一個檔或目錄。
FileDialogMode FILE_DIALOG_MODE_SAVE_FILE = 4
當檔案存在時,對話方塊會發出警告。
enum WindowMode: 🔗
WindowMode WINDOW_MODE_WINDOWED = 0
視窗模式,即 Window 不佔據整個螢幕(除非設定為螢幕的大小)。
WindowMode WINDOW_MODE_MINIMIZED = 1
最小化視窗模式,即 Window 在視窗管理器的視窗列表中既不可見也不可用。通常發生在按下最小化按鈕時。
WindowMode WINDOW_MODE_MAXIMIZED = 2
最大化視窗模式,即 Window 會佔據整個螢幕區域,工作列除外,並且會顯示邊框。通常發生在按下最大化按鈕時。
WindowMode WINDOW_MODE_FULLSCREEN = 3
Full screen mode with full multi-window support.
Full screen window covers the entire display area of a screen and has no decorations. The display's video mode is not changed.
On Android: This enables immersive mode.
On macOS: A new desktop is used to display the running project.
Note: Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling full screen mode.
WindowMode WINDOW_MODE_EXCLUSIVE_FULLSCREEN = 4
A single window full screen mode. This mode has less overhead, but only one window can be open on a given screen at a time (opening a child window or application switching will trigger a full screen transition).
Full screen window covers the entire display area of a screen and has no border or decorations. The display's video mode is not changed.
Note: This mode might not work with screen recording software.
On Android: This enables immersive mode.
On Windows: Depending on video driver, full screen transition might cause screens to go black for a moment.
On macOS: A new desktop is used to display the running project. Exclusive full screen mode prevents Dock and Menu from showing up when the mouse pointer is hovering the edge of the screen.
On Linux (X11): Exclusive full screen mode bypasses compositor.
On Linux (Wayland): Equivalent to WINDOW_MODE_FULLSCREEN.
Note: Regardless of the platform, enabling full screen will change the window size to match the monitor's size. Therefore, make sure your project supports multiple resolutions when enabling full screen mode.
enum ProgressState: 🔗
ProgressState PROGRESS_STATE_NOPROGRESS = 0
Stops displaying progress and returns the button to its normal state.
ProgressState PROGRESS_STATE_INDETERMINATE = 1
The progress indicator shows an indeterminate progress.
On Windows, the progress indicator does not grow in size, but cycles repeatedly along the length of the taskbar button by default.
ProgressState PROGRESS_STATE_NORMAL = 2
The progress indicator shows progress normally.
ProgressState PROGRESS_STATE_ERROR = 3
The progress indicator shows that an error has occurred.
On Windows, the progress indicator turns red by default to show that an error has occurred in one of the windows that is broadcasting progress.
ProgressState PROGRESS_STATE_PAUSED = 4
The progress indicator shows it was paused.
On Windows, the progress indicator turns yellow by default to show that progress is currently stopped in one of the windows but can be resumed by the user.
enum WindowFlags: 🔗
WindowFlags WINDOW_FLAG_RESIZE_DISABLED = 0
該視窗不能通過拖動其調整大小的手柄來調整大小。但仍然可以使用 window_set_size() 調整視窗大小。全屏視窗會忽略該旗標。
WindowFlags WINDOW_FLAG_BORDERLESS = 1
該視窗沒有原生標題列和其他裝飾。全屏視窗會忽略該旗標。
WindowFlags WINDOW_FLAG_ALWAYS_ON_TOP = 2
該視窗懸浮在所有其他視窗之上。全屏視窗會忽略該旗標。
WindowFlags WINDOW_FLAG_TRANSPARENT = 3
The window background can be transparent.
Note: This flag has no effect if is_window_transparency_available() returns false.
Note: Transparency support is implemented on Linux (X11/Wayland), macOS, and Windows, but availability might vary depending on GPU driver, display manager, and compositor capabilities.
Note: Transparency support is implemented on Android, but can only be enabled via ProjectSettings.display/window/per_pixel_transparency/allowed. This flag has no effect on Android.
WindowFlags WINDOW_FLAG_NO_FOCUS = 4
該視窗無法獲得焦點。無聚焦視窗會忽略除滑鼠點擊外的所有輸入。
WindowFlags WINDOW_FLAG_POPUP = 5
視窗是功能表或 OptionButton 下拉式功能表的一部分。當視窗可見時,不能更改該旗標。活動的快顯視窗會以獨佔的形式接收所有輸入,但不會從其父視窗竊取焦點。當在其外部點擊或切換套用程式時,快顯視窗將會自動關閉。 快顯視窗必須已經設定了臨時父級(參見 window_set_transient())。
WindowFlags WINDOW_FLAG_EXTEND_TO_TITLE = 6
視窗內容擴充到視窗的全部大小。與無邊框視窗不同,框架仍保持不變,可以調整視窗大小,標題列是透明的,但具有最小化/最大化/關閉按鈕。
使用 window_set_window_buttons_offset() 調整最小化/最大化/關閉按鈕的偏移量。
使用 window_get_safe_title_margins() 確定標題列下方未被裝飾覆蓋的區域。
注意:該旗標僅在 macOS 上實作。
WindowFlags WINDOW_FLAG_MOUSE_PASSTHROUGH = 7
所有滑鼠事件都被傳遞到同一套用程式的底層視窗。
WindowFlags WINDOW_FLAG_SHARP_CORNERS = 8
Window style is overridden, forcing sharp corners.
Note: This flag is implemented only on Windows (11).
WindowFlags WINDOW_FLAG_EXCLUDE_FROM_CAPTURE = 9
Window is excluded from screenshots taken by screen_get_image(), screen_get_image_rect(), and screen_get_pixel().
Note: This flag is implemented on macOS and Windows (10, 20H1).
Note: Setting this flag will prevent standard screenshot methods from capturing a window image, but does NOT guarantee that other apps won't be able to capture an image. It should not be used as a DRM or security measure.
WindowFlags WINDOW_FLAG_POPUP_WM_HINT = 10
Signals the window manager that this window is supposed to be an implementation-defined "popup" (usually a floating, borderless, untileable and immovable child window).
WindowFlags WINDOW_FLAG_MINIMIZE_DISABLED = 11
Window minimize button is disabled.
Note: This flag is implemented on macOS and Windows.
WindowFlags WINDOW_FLAG_MAXIMIZE_DISABLED = 12
Window maximize button is disabled.
Note: This flag is implemented on macOS and Windows.
WindowFlags WINDOW_FLAG_MAX = 13
Represents the size of the WindowFlags enum.
enum WindowEvent: 🔗
WindowEvent WINDOW_EVENT_MOUSE_ENTER = 0
Sent when the mouse pointer enters the window.
WindowEvent WINDOW_EVENT_MOUSE_EXIT = 1
Sent when the mouse pointer exits the window.
WindowEvent WINDOW_EVENT_FOCUS_IN = 2
Sent when the window grabs focus.
WindowEvent WINDOW_EVENT_FOCUS_OUT = 3
Sent when the window loses focus.
WindowEvent WINDOW_EVENT_CLOSE_REQUEST = 4
Sent when the user has attempted to close the window (e.g. close button is pressed).
WindowEvent WINDOW_EVENT_GO_BACK_REQUEST = 5
Sent when the device "Back" button is pressed.
Note: This event is implemented only on Android.
WindowEvent WINDOW_EVENT_DPI_CHANGE = 6
Sent when the window is moved to the display with different DPI, or display DPI is changed.
Note: This flag is implemented only on macOS and Linux (Wayland).
WindowEvent WINDOW_EVENT_TITLEBAR_CHANGE = 7
Sent when the window title bar decoration is changed (e.g. WINDOW_FLAG_EXTEND_TO_TITLE is set or window entered/exited full screen mode).
Note: This flag is implemented only on macOS.
WindowEvent WINDOW_EVENT_FORCE_CLOSE = 8
Sent when the window has been forcibly closed by the display server. The window will immediately hide and clean any internal rendering references.
Note: This flag is implemented only on Linux (Wayland).
WindowEvent WINDOW_EVENT_OUTPUT_MAX_LINEAR_VALUE_CHANGED = 9
Sent when the output max linear value returned by Window.get_output_max_linear_value() has changed.
This occurs when HDR output is enabled or disabled and when any HDR output luminance values of the window have changed, such as when the player adjusts their screen brightness setting or moves the window to a different screen.
enum WindowResizeEdge: 🔗
WindowResizeEdge WINDOW_EDGE_TOP_LEFT = 0
Top-left edge of a window.
WindowResizeEdge WINDOW_EDGE_TOP = 1
Top edge of a window.
WindowResizeEdge WINDOW_EDGE_TOP_RIGHT = 2
Top-right edge of a window.
WindowResizeEdge WINDOW_EDGE_LEFT = 3
Left edge of a window.
WindowResizeEdge WINDOW_EDGE_RIGHT = 4
Right edge of a window.
WindowResizeEdge WINDOW_EDGE_BOTTOM_LEFT = 5
Bottom-left edge of a window.
WindowResizeEdge WINDOW_EDGE_BOTTOM = 6
視窗的底部邊緣。
WindowResizeEdge WINDOW_EDGE_BOTTOM_RIGHT = 7
Bottom-right edge of a window.
WindowResizeEdge WINDOW_EDGE_MAX = 8
Represents the size of the WindowResizeEdge enum.
enum VSyncMode: 🔗
VSyncMode VSYNC_DISABLED = 0
No vertical synchronization, which means the engine will display frames as fast as possible (tearing may be visible). Framerate is unlimited (regardless of Engine.max_fps).
VSyncMode VSYNC_ENABLED = 1
Default vertical synchronization mode, the image is displayed only on vertical blanking intervals (no tearing is visible). Framerate is limited by the monitor refresh rate (regardless of Engine.max_fps).
VSyncMode VSYNC_ADAPTIVE = 2
Behaves like VSYNC_DISABLED when the framerate drops below the screen's refresh rate to reduce stuttering (tearing may be visible). Otherwise, vertical synchronization is enabled to avoid tearing. Framerate is limited by the monitor refresh rate (regardless of Engine.max_fps). Behaves like VSYNC_ENABLED when using the Compatibility rendering method.
VSyncMode VSYNC_MAILBOX = 3
Displays the most recent image in the queue on vertical blanking intervals, while rendering to the other images (no tearing is visible). Framerate is unlimited (regardless of Engine.max_fps).
Although not guaranteed, the images can be rendered as fast as possible, which may reduce input lag (also called "Fast" V-Sync mode). VSYNC_MAILBOX works best when at least twice as many frames as the display refresh rate are rendered. Behaves like VSYNC_ENABLED when using the Compatibility rendering method.
enum HandleType: 🔗
HandleType DISPLAY_HANDLE = 0
Display handle:
Linux (X11):
X11::Display*for the display.Linux (Wayland):
wl_displayfor the display.Android:
EGLDisplayfor the display.
HandleType WINDOW_HANDLE = 1
Window handle:
Windows:
HWNDfor the window.Linux (X11):
X11::Window*for the window.Linux (Wayland):
wl_surfacefor the window.macOS:
NSWindow*for the window.iOS:
UIViewController*for the view controller.Android:
jObjectfor the activity.
HandleType WINDOW_VIEW = 2
Window view:
Windows:
HDCfor the window (only with the Compatibility renderer).macOS:
NSView*for the window main view.iOS:
UIView*for the window main view.
HandleType OPENGL_CONTEXT = 3
OpenGL context (only with the Compatibility renderer):
Windows:
HGLRCfor the window (native GL), orEGLContextfor the window (ANGLE).Linux (X11):
GLXContext*for the window.Linux (Wayland):
EGLContextfor the window.macOS:
NSOpenGLContext*for the window (native GL), orEGLContextfor the window (ANGLE).Android:
EGLContextfor the window.
HandleType EGL_DISPLAY = 4
Windows:
EGLDisplayfor the window (ANGLE).macOS:
EGLDisplayfor the window (ANGLE).Linux (Wayland):
EGLDisplayfor the window.
HandleType EGL_CONFIG = 5
Windows:
EGLConfigfor the window (ANGLE).macOS:
EGLConfigfor the window (ANGLE).Linux (Wayland):
EGLConfigfor the window.
HandleType GLX_VISUALID = 6
The GLX VisualID for the window.
Note: Only available on Linux when using X11.
HandleType GLX_FBCONFIG = 7
The GLXFBConfig for the window.
Note: Only available on Linux when using X11.
enum TTSUtteranceEvent: 🔗
TTSUtteranceEvent TTS_UTTERANCE_STARTED = 0
發言開始。
TTSUtteranceEvent TTS_UTTERANCE_ENDED = 1
發言順利結束。
TTSUtteranceEvent TTS_UTTERANCE_CANCELED = 2
發言取消,或者 TTS 服務無法處理。
TTSUtteranceEvent TTS_UTTERANCE_BOUNDARY = 3
發言到達單詞或句子的邊界。
常數
INVALID_SCREEN = -1 🔗
The ID that refers to a screen that does not exist. This is returned by some DisplayServer methods if no screen matches the requested result.
SCREEN_WITH_MOUSE_FOCUS = -4 🔗
Represents the screen containing the mouse pointer.
Note: On Android, iOS, Web, and Linux (Wayland), this constant always represents the screen at index 0.
SCREEN_WITH_KEYBOARD_FOCUS = -3 🔗
Represents the screen containing the window with the keyboard focus.
Note: On Android, iOS, Web, and Linux (Wayland), this constant always represents the screen at index 0.
SCREEN_PRIMARY = -2 🔗
Represents the primary screen.
Note: On Android, iOS, Web, and Linux (Wayland), this constant always represents the screen at index 0.
SCREEN_OF_MAIN_WINDOW = -1 🔗
Represents the screen where the main window is located. This is usually the default value in functions that allow specifying one of several screens.
Note: On Android, iOS, Web, and Linux (Wayland), this constant always represents the screen at index 0.
MAIN_WINDOW_ID = 0 🔗
主視窗的 ID,可以傳給需要 window_id 的方法,該視窗由引擎生成。
INVALID_WINDOW_ID = -1 🔗
The ID that refers to a nonexistent window. This is returned by some DisplayServer methods if no window matches the requested result.
INVALID_INDICATOR_ID = -1 🔗
The ID that refers to a nonexistent application status indicator.
方法說明
RID accessibility_create_element(window_id: int, role: AccessibilityRole) 🔗
已棄用: Use AccessibilityServer instead.
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.
RID accessibility_create_sub_element(parent_rid: RID, role: AccessibilityRole, insert_pos: int = -1) 🔗
已棄用: Use AccessibilityServer instead.
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.
RID accessibility_create_sub_text_edit_elements(parent_rid: RID, shaped_text: RID, min_height: float, insert_pos: int = -1, is_last_line: bool = false) 🔗
已棄用: Use AccessibilityServer instead.
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.
Variant accessibility_element_get_meta(id: RID) const 🔗
已棄用: Use AccessibilityServer instead.
Returns the metadata of the accessibility element id.
void accessibility_element_set_meta(id: RID, meta: Variant) 🔗
已棄用: Use AccessibilityServer instead.
Sets the metadata of the accessibility element id to meta.
void accessibility_free_element(id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Frees the accessibility element id created by accessibility_create_element(), accessibility_create_sub_element(), or accessibility_create_sub_text_edit_elements().
RID accessibility_get_window_root(window_id: int) const 🔗
已棄用: Use AccessibilityServer instead.
Returns the main accessibility element of the OS native window.
bool accessibility_has_element(id: RID) const 🔗
已棄用: Use AccessibilityServer instead.
Returns true if id is a valid accessibility element.
int accessibility_screen_reader_active() const 🔗
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 ProjectSettings.accessibility/general/accessibility_support to 1.
void accessibility_set_window_focused(window_id: int, focused: bool) 🔗
已棄用: Use AccessibilityServer instead.
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.
void accessibility_set_window_rect(window_id: int, rect_out: Rect2, rect_in: Rect2) 🔗
已棄用: Use AccessibilityServer instead.
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.
int accessibility_should_increase_contrast() const 🔗
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.
int accessibility_should_reduce_animation() const 🔗
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.
int accessibility_should_reduce_transparency() const 🔗
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.
void accessibility_update_add_action(id: RID, action: AccessibilityAction, callable: Callable) 🔗
已棄用: Use AccessibilityServer instead.
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.
void accessibility_update_add_child(id: RID, child_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Adds a child accessibility element.
Note: Node children and sub-elements are added to the child list automatically.
void accessibility_update_add_custom_action(id: RID, action_id: int, action_description: String) 🔗
已棄用: Use AccessibilityServer instead.
Adds support for a custom accessibility action. action_id is passed as an argument to the callback of ACTION_CUSTOM action.
已棄用: Use AccessibilityServer instead.
Adds an element that is controlled by this element.
已棄用: Use AccessibilityServer instead.
Adds an element that describes this element.
已棄用: Use AccessibilityServer instead.
Adds an element that details this element.
已棄用: Use AccessibilityServer instead.
Adds an element that this element flow into.
已棄用: Use AccessibilityServer instead.
Adds an element that labels this element.
已棄用: Use AccessibilityServer instead.
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.
void accessibility_update_set_active_descendant(id: RID, other_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Adds an element that is an active descendant of this element.
void accessibility_update_set_background_color(id: RID, color: Color) 🔗
已棄用: Use AccessibilityServer instead.
Sets element background color.
void accessibility_update_set_bounds(id: RID, rect: Rect2) 🔗
已棄用: Use AccessibilityServer instead.
Sets element bounding box, relative to the node position.
void accessibility_update_set_checked(id: RID, checekd: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets element checked state.
void accessibility_update_set_classname(id: RID, classname: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element class name.
void accessibility_update_set_color_value(id: RID, color: Color) 🔗
已棄用: Use AccessibilityServer instead.
Sets element color value.
void accessibility_update_set_description(id: RID, description: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element accessibility description.
void accessibility_update_set_error_message(id: RID, other_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets an element which contains an error message for this element.
void accessibility_update_set_extra_info(id: RID, name: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element accessibility extra information added to the element name.
void accessibility_update_set_flag(id: RID, flag: AccessibilityFlags, value: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets element flag.
void accessibility_update_set_focus(id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets currently focused element.
void accessibility_update_set_foreground_color(id: RID, color: Color) 🔗
已棄用: Use AccessibilityServer instead.
Sets element foreground color.
void accessibility_update_set_in_page_link_target(id: RID, other_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets target element for the link.
void accessibility_update_set_language(id: RID, language: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element text language.
void accessibility_update_set_list_item_count(id: RID, size: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets number of items in the list.
void accessibility_update_set_list_item_expanded(id: RID, expanded: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets list/tree item expanded status.
void accessibility_update_set_list_item_index(id: RID, index: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets the position of the element in the list.
void accessibility_update_set_list_item_level(id: RID, level: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets the hierarchical level of the element in the list.
void accessibility_update_set_list_item_selected(id: RID, selected: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets list/tree item selected status.
void accessibility_update_set_list_orientation(id: RID, vertical: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets the orientation of the list elements.
void accessibility_update_set_live(id: RID, live: AccessibilityLiveMode) 🔗
已棄用: Use AccessibilityServer instead.
Sets the priority of the live region updates.
void accessibility_update_set_member_of(id: RID, group_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets the element to be a member of the group.
void accessibility_update_set_name(id: RID, name: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element accessibility name.
void accessibility_update_set_next_on_line(id: RID, other_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets next element on the line.
void accessibility_update_set_num_jump(id: RID, jump: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets numeric value jump.
void accessibility_update_set_num_range(id: RID, min: float, max: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets numeric value range.
void accessibility_update_set_num_step(id: RID, step: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets numeric value step.
void accessibility_update_set_num_value(id: RID, position: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets numeric value.
void accessibility_update_set_placeholder(id: RID, placeholder: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets placeholder text.
void accessibility_update_set_popup_type(id: RID, popup: AccessibilityPopupType) 🔗
已棄用: Use AccessibilityServer instead.
Sets popup type for popup buttons.
void accessibility_update_set_previous_on_line(id: RID, other_id: RID) 🔗
已棄用: Use AccessibilityServer instead.
Sets previous element on the line.
void accessibility_update_set_role(id: RID, role: AccessibilityRole) 🔗
已棄用: Use AccessibilityServer instead.
Sets element accessibility role.
void accessibility_update_set_role_description(id: RID, description: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element accessibility role description text.
void accessibility_update_set_scroll_x(id: RID, position: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets scroll bar x position.
void accessibility_update_set_scroll_x_range(id: RID, min: float, max: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets scroll bar x range.
void accessibility_update_set_scroll_y(id: RID, position: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets scroll bar y position.
void accessibility_update_set_scroll_y_range(id: RID, min: float, max: float) 🔗
已棄用: Use AccessibilityServer instead.
Sets scroll bar y range.
void accessibility_update_set_shortcut(id: RID, shortcut: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets the list of keyboard shortcuts used by element.
void accessibility_update_set_state_description(id: RID, description: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets human-readable description of the current checked state.
void accessibility_update_set_table_cell_position(id: RID, row_index: int, column_index: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets cell position in the table.
void accessibility_update_set_table_cell_span(id: RID, row_span: int, column_span: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets cell row/column span.
void accessibility_update_set_table_column_count(id: RID, count: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets number of columns in the table.
void accessibility_update_set_table_column_index(id: RID, index: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets position of the column.
void accessibility_update_set_table_row_count(id: RID, count: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets number of rows in the table.
void accessibility_update_set_table_row_index(id: RID, index: int) 🔗
已棄用: Use AccessibilityServer instead.
Sets position of the row in the table.
void accessibility_update_set_text_align(id: RID, align: HorizontalAlignment) 🔗
已棄用: Use AccessibilityServer instead.
Sets element text alignment.
void accessibility_update_set_text_decorations(id: RID, underline: bool, strikethrough: bool, overline: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets text underline/overline/strikethrough.
void accessibility_update_set_text_orientation(id: RID, vertical: bool) 🔗
已棄用: Use AccessibilityServer instead.
Sets text orientation.
void accessibility_update_set_text_selection(id: RID, text_start_id: RID, start_char: int, text_end_id: RID, end_char: int) 🔗
已棄用: Use AccessibilityServer instead.
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.
void accessibility_update_set_tooltip(id: RID, tooltip: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets tooltip text.
void accessibility_update_set_transform(id: RID, transform: Transform2D) 🔗
已棄用: Use AccessibilityServer instead.
Sets element 2D transform.
void accessibility_update_set_url(id: RID, url: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets link URL.
void accessibility_update_set_value(id: RID, value: String) 🔗
已棄用: Use AccessibilityServer instead.
Sets element text value.
void beep() const 🔗
Plays the beep sound from the operative system, if possible. Because it comes from the OS, the beep sound will be audible even if the application is muted. It may also be disabled for the entire OS by the user.
Note: This method is implemented on macOS, Linux (X11/Wayland), and Windows.
String clipboard_get() const 🔗
如果可能,將使用者的剪貼板作為字串返回。
Image clipboard_get_image() const 🔗
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.
String clipboard_get_primary() const 🔗
Returns the user's primary clipboard as a string if possible. This is the clipboard that is set when the user selects text in any application, rather than when pressing Ctrl + C. The clipboard data can then be pasted by clicking the middle mouse button in any application that supports the primary clipboard mechanism.
Note: This method is only implemented on Linux (X11/Wayland).
如果使用者的剪貼板中有內容,則返回 true。
bool clipboard_has_image() const 🔗
如果使用者的剪貼板中有內容,則返回 true。
void clipboard_set(clipboard: String) 🔗
將使用者的剪貼板內容設定為給定的字串。
void clipboard_set_primary(clipboard_primary: String) 🔗
Sets the user's primary clipboard content to the given string. This is the clipboard that is set when the user selects text in any application, rather than when pressing Ctrl + C. The clipboard data can then be pasted by clicking the middle mouse button in any application that supports the primary clipboard mechanism.
Note: This method is only implemented on Linux (X11/Wayland).
bool color_picker(callback: Callable) 🔗
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).
int create_status_indicator(icon: Texture2D, tooltip: String, callback: Callable) 🔗
Creates a new application status indicator with the specified icon, tooltip, and activation callback.
callback should take two arguments: the pressed mouse button (one of the MouseButton constants) and the click position in screen coordinates (a Vector2i).
CursorShape cursor_get_shape() const 🔗
返回預設滑鼠游標形狀,由 cursor_set_shape() 設定。
void cursor_set_custom_image(cursor: Resource, shape: CursorShape = 0, hotspot: Vector2 = Vector2(0, 0)) 🔗
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.
void cursor_set_shape(shape: CursorShape) 🔗
設定預設的滑鼠游標形狀。游標的外觀將根據使用者的作業系統和滑鼠游標主題而變化。另見 cursor_get_shape() 和 cursor_set_custom_image()。
void delete_status_indicator(id: int) 🔗
Removes the application status indicator.
Error dialog_input_text(title: String, description: String, existing_text: String, callback: Callable) 🔗
Shows a text input dialog which uses the operating system's native look-and-feel. callback should accept a single String parameter which contains the text field's contents.
Note: This method is implemented if the display server has the FEATURE_NATIVE_DIALOG_INPUT feature. Supported platforms include macOS, Windows, and Android.
Error dialog_show(title: String, description: String, buttons: PackedStringArray, callback: Callable) 🔗
Shows a text dialog which uses the operating system's native look-and-feel. callback should accept a single int parameter which corresponds to the index of the pressed button.
Note: This method is implemented if the display server has the FEATURE_NATIVE_DIALOG feature. Supported platforms include macOS, Windows, and Android.
void enable_for_stealing_focus(process_id: int) 🔗
讓程序 PID process_id 竊取該視窗的焦點。換句話說,會禁用作業系統對指定 PID 的焦點竊取保護。
注意:該方法僅在 Windows 上實作。
Error file_dialog_show(title: String, current_directory: String, filename: String, show_hidden: bool, mode: FileDialogMode, filters: PackedStringArray, callback: Callable, parent_window_id: int = 0) 🔗
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 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.
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 OS.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 FILE_DIALOG_MODE_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.
Error file_dialog_with_options_show(title: String, current_directory: String, root: String, filename: String, show_hidden: bool, mode: FileDialogMode, filters: PackedStringArray, options: Array[Dictionary], callback: Callable, parent_window_id: int = 0) 🔗
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 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 OS.get_granted_permissions() to get a list of saved bookmarks.
void force_process_and_drop_events() 🔗
強制視窗管理器進行處理,會忽略所有 InputEvent。另見 process_events()。
注意:這個方法在 Windows 和 macOS 上實作。
Color get_accent_color() const 🔗
Returns OS theme accent color. Returns Color(0, 0, 0, 0), if accent color is unknown.
Note: This method is implemented on macOS, Windows, Android, and Linux (X11/Wayland).
Color get_base_color() const 🔗
Returns the OS theme base color (default control background). Returns Color(0, 0, 0, 0) if the base color is unknown.
Note: This method is implemented on macOS, Windows, and Android.
Array[Rect2] get_display_cutouts() const 🔗
返回 Rect2 的 Array,其中每個都是顯示切口或凹口的邊界矩形。這些是相機和傳感器使用的無邊框螢幕上的非功能區域。如果裝置沒有切口,則返回一個空陣列。另見 get_display_safe_area()。
注意:目前僅在 Android 上實作。其他平臺將返回一個空陣列,即使它們確實有顯示切口或凹口。
Rect2i get_display_safe_area() const 🔗
Returns the unobscured area of the display where interactive controls should be rendered. See also get_display_cutouts().
Note: Currently only implemented on Android and iOS. On other platforms, screen_get_usable_rect(SCREEN_OF_MAIN_WINDOW) will be returned as a fallback. See also screen_get_usable_rect().
int get_keyboard_focus_screen() const 🔗
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.
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).
int get_primary_screen() const 🔗
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.
int get_screen_count() const 🔗
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.
int get_screen_from_rect(rect: Rect2) const 🔗
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.
如果對話方塊中的確定和取消按鈕進行了交換,則返回 true。在 Windows 和 UWP 上預設啟用,從而遵循介面規範,可以使用 ProjectSettings.gui/common/swap_cancel_ok 開關。
注意:由 dialog_show() 等生成的原生對話方塊不受影響。
int get_window_at_screen_position(position: Vector2i) const 🔗
Returns the ID of the window at the specified screen position (in pixels). On multi-monitor setups, the screen position is relative to the virtual desktop area. On multi-monitor setups with different screen resolutions or orientations, the origin may be located outside any display like this:
* (0, 0) +-------+
| |
+-------------+ | |
| | | |
| | | |
+-------------+ +-------+
PackedInt32Array get_window_list() const 🔗
返回屬於該程序的 Godot 視窗 ID 列表。
注意:這個列表中不含原生對話方塊。
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new checkable item with text label to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new checkable item with text label and icon icon to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new item with text label and icon icon to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new radio-checkable item with text label and icon icon to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See 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).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new item with text label to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new item with text label to the global menu with ID menu_root.
Contrarily to normal binary items, multistate items can have more than two states, as defined by max_states. Each press or activate of the item will increase the state by one. The default value is defined by default_state.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: By default, there's no indication of the current item state, it should be changed manually.
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented only on macOS.
Supported system menu IDs:
"_main" - Main menu (macOS).
"_dock" - Dock popup menu (macOS).
"_apple" - Apple menu (macOS, custom items added before "Services").
"_window" - Window menu (macOS, custom items added after "Bring All to Front").
"_help" - Help menu (macOS).
已棄用: Use NativeMenu or PopupMenu instead.
Adds a new radio-checkable item with text label to the global menu with ID menu_root.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A (Ctrl + A).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See 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).
已棄用: Use NativeMenu or PopupMenu instead.
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).
已棄用: Use NativeMenu or PopupMenu instead.
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).
已棄用: Use NativeMenu or PopupMenu instead.
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).
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的快捷鍵。快捷鍵是能夠啟動該功能表專案的特殊按鍵組合,無論該控制項是否有焦點。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的回呼函式。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回 ID 為 menu_root 的全域選單中功能表專案的數量。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的圖示。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的水平偏移量。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
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.
已棄用: Use NativeMenu or PopupMenu instead.
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.
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的快捷鍵回呼函式。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回多狀態項的狀態數。詳見 global_menu_add_multistate_item()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回多狀態項的狀態。詳見 global_menu_add_multistate_item()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的子功能表 ID。關於如何新增子功能表的更多資訊見 global_menu_add_submenu_item()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回指定功能表專案的中繼資料,可能是任何型別。中繼資料可以使用 global_menu_set_item_tag() 設定,可以方法地為功能表專案關聯本文資料。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案的文字。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
返回索引為 idx 的功能表專案所關聯的工具提示。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
Returns Dictionary of supported system menu IDs and names.
Note: This method is implemented only on macOS.
已棄用: Use NativeMenu or PopupMenu instead.
如果索引為 idx 的功能表專案能夠以某種方式選中,即有核取方塊或選項按鈕,則返回 true。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
如果索引為 idx 的功能表專案處於選中狀態,則返回 true。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
如果索引為 idx 的功能表專案處於禁用狀態,則返回 true。禁用狀態下無法被選中,也無法啟動動作。
關於如何禁用功能表專案的更多資訊見 global_menu_set_item_disabled()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
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.
已棄用: Use NativeMenu or PopupMenu instead.
如果索引為 idx 的功能表專案為選項按鈕風格,則返回 true。
注意:僅為裝飾作用;必須自行為單選組新增選中、取消選中的邏輯。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
從全域功能表 menu_root 移除索引為 idx 的功能表專案。
注意:位置在被移除功能表專案之後的功能表專案的索引號都會減一。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的快捷鍵。keycode 可以是單一 Key,也可以是 KeyModifierMask 和 Key 用按位元或操作進行的組合,例如 KEY_MASK_CTRL | KEY_A(Ctrl + A)。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的回呼函式。回呼函式會在按下功能表專案時發出。
注意:callback Callable 只接受一個 Variant 參數,傳入 Callable 的參數是建立功能表專案時傳給 tag 參數的值。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案是否為核取方塊。如果為 false,則會將該功能表專案的型別設定為純文字。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的選中狀態。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
啟用/禁用索引為 idx 的功能表專案。禁用狀態下無法被選中,也無法啟動動作。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
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.
已棄用: Use NativeMenu or PopupMenu instead.
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.
已棄用: Use NativeMenu or PopupMenu instead.
替換指定索引 idx 的 Texture2D 圖示。
注意:該方法僅在 macOS 上實作。
注意:該方法不支援 macOS 的“_dock”功能表專案。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的水平偏移量。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的回呼函式。回呼函式會在啟動快捷鍵時發出。
注意:key_callback Callable 只接受一個 Variant 參數,傳入 Callable 的參數是建立功能表專案時傳給 tag 參數的值。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定多狀態項的狀態數。詳見 global_menu_add_multistate_item()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
將索引為 idx 的功能表專案設定為選項按鈕風格。如果為 false,則會將該功能表專案的型別設定為純文字。
注意:僅為裝飾作用;必須自行為單選組新增選中、取消選中的邏輯。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定多狀態項的狀態。詳見 global_menu_add_multistate_item()。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的子功能表。子功能表是某個全域選單根功能表專案的 ID,點擊該功能表專案時會顯示子功能表。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定指定功能表專案的中繼資料,可以是任何型別。後續可以使用 global_menu_get_item_tag() 獲取,可以方法地為功能表專案關聯本文資料。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的文字。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
設定索引為 idx 的功能表專案的工具提示 String。
注意:該方法僅在 macOS 上實作。
已棄用: Use NativeMenu or PopupMenu instead.
Registers callables to emit when the menu is respectively about to show or closed. Callback methods should have zero arguments.
bool has_additional_outputs() const 🔗
Returns true if any additional outputs have been registered via register_additional_output().
bool has_feature(feature: Feature) const 🔗
如果目前的 DisplayServer 支援指定的功能 feature,則返回 true,否則返回 false。
bool has_hardware_keyboard() const 🔗
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.
void help_set_search_callbacks(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.
Vector2i ime_get_selection() const 🔗
返回輸入法編輯器編組字串中選中的文字,Vector2i 的 x 分量為游標的位置,y 則為所選項的長度。
注意:該方法僅在 macOS 上實作。
返回輸入法編輯器視窗中的編組字串。
注意:該方法僅在 macOS 上實作。
Returns true if OS is using dark mode.
Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11/Wayland).
bool is_dark_mode_supported() const 🔗
Returns true if OS supports dark mode.
Note: This method is implemented on Android, iOS, macOS, Windows, and Linux (X11/Wayland).
bool is_in_pip_mode(window_id: int = 0) 🔗
Returns true if the application is in picture-in-picture mode.
Note: This method is implemented on Android.
bool is_touchscreen_available() const 🔗
如果觸摸事件可用(Android 或 iOS)、在 Web 平臺上偵測到該功能或如果 ProjectSettings.input_devices/pointing/emulate_touch_from_mouse 為 true 時,則返回 true。
bool is_window_transparency_available() const 🔗
Returns true if the window background can be made transparent. This method returns false if ProjectSettings.display/window/per_pixel_transparency/allowed is set to false, or if transparency is not supported by the renderer or OS compositor.
int keyboard_get_current_layout() const 🔗
Returns active keyboard layout index.
Note: This method is implemented on Linux (X11/Wayland), macOS, and Windows.
Key keyboard_get_keycode_from_physical(keycode: Key) const 🔗
Converts a physical (US QWERTY) keycode to one in the active keyboard layout.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
Key keyboard_get_label_from_physical(keycode: Key) const 🔗
Converts a physical (US QWERTY) keycode to localized label printed on the key in the active keyboard layout.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
int keyboard_get_layout_count() const 🔗
Returns the number of keyboard layouts.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
String keyboard_get_layout_language(index: int) const 🔗
Returns the ISO-639/BCP-47 language code of the keyboard layout at position index.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
String keyboard_get_layout_name(index: int) const 🔗
Returns the localized name of the keyboard layout at position index.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
void keyboard_set_current_layout(index: int) 🔗
Sets the active keyboard layout.
Note: This method is implemented on Linux (X11/Wayland), macOS and Windows.
BitField[MouseButtonMask] mouse_get_button_state() const 🔗
以位元遮罩的形式返回目前滑鼠按鍵的狀態(各個按鈕是否處於按下狀態)。如果同時按下了多個按鍵,則會同時設定多個比特位。等價於 Input.get_mouse_button_mask()。
MouseMode mouse_get_mode() const 🔗
返回目前的滑鼠模式。另見 mouse_set_mode()。
Vector2i mouse_get_position() const 🔗
返回滑鼠游標的目前位置,使用螢幕座標。
void mouse_set_mode(mouse_mode: MouseMode) 🔗
設定目前的滑鼠模式。另見 mouse_get_mode()。
void pip_mode_enter(window_id: int = 0) 🔗
Enters picture-in-picture mode.
Note: This method is implemented on Android.
void pip_mode_set_aspect_ratio(numerator: int, denominator: int, window_id: int = 0) 🔗
Specifies the aspect ratio for picture-in-picture mode.
Note: This method is implemented on Android.
void pip_mode_set_auto_enter_on_background(auto_enter_on_background: bool, window_id: int = 0) 🔗
Specifies whether picture-in-picture mode should be entered automatically when the application goes in the background.
Note: This method is implemented on Android.
void process_events() 🔗
執行視窗管理器處理,包括輸入的清空。另見 force_process_and_drop_events()、Input.flush_buffered_events()、Input.use_accumulated_input。
void register_additional_output(object: 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.
int screen_get_dpi(screen: int = -1) const 🔗
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.
Image screen_get_image(screen: int = -1) const 🔗
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.
Image screen_get_image_rect(rect: Rect2i) const 🔗
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.
float screen_get_max_scale() const 🔗
返回所有螢幕的最大縮放係數。
注意:在 macOS 上,如果系統中至少有一個 hiDPI(Retina)螢幕,則返回值為 2.0,在所有其他情況下返回值為 1.0 。
注意:該方法僅在 macOS 上實作。
ScreenOrientation screen_get_orientation(screen: int = -1) const 🔗
Returns the screen's current orientation. See also screen_set_orientation(). Returns SCREEN_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 SCREEN_LANDSCAPE.
Color screen_get_pixel(position: Vector2i) const 🔗
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.
Vector2i screen_get_position(screen: int = -1) const 🔗
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.
float screen_get_refresh_rate(screen: int = -1) const 🔗
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.
float screen_get_scale(screen: int = -1) const 🔗
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.
Vector2i screen_get_size(screen: int = -1) const 🔗
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.
Rect2i screen_get_usable_rect(screen: int = -1) const 🔗
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)).
bool screen_is_kept_on() const 🔗
如果作業系統的節電措施永遠不會關閉螢幕,則返回 true。另見 screen_set_keep_on()。
void screen_set_keep_on(enable: bool) 🔗
設定螢幕是否總是不會被作業系統的節能措施關閉。另見 screen_is_kept_on()。
void screen_set_orientation(orientation: ScreenOrientation, screen: int = -1) 🔗
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 ProjectSettings.display/window/handheld/orientation is not set to SCREEN_SENSOR.
void set_hardware_keyboard_connection_change_callback(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.
Sets the application icon and icons of all windows with an Image. To use icons in the operating system's native format, use set_native_icon() instead.
Note: Requires support for FEATURE_ICON.
void set_native_icon(filename: String) 🔗
Sets the window icon (usually displayed in the top-left corner) in the operating system's native format. The file at filename must be in .ico format on Windows or .icns on macOS. By using specially crafted .ico or .icns icons, 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.
void set_system_theme_change_callback(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).
void show_emoji_and_symbol_picker() const 🔗
Opens system emoji and symbol picker.
Note: This method is implemented on macOS and Windows.
Rect2 status_indicator_get_rect(id: int) const 🔗
Returns the rectangle for the given status indicator id in screen coordinates. If the status indicator is not visible, returns an empty Rect2.
Note: This method is implemented on macOS and Windows.
void status_indicator_set_callback(id: int, callback: Callable) 🔗
Sets the application status indicator activation callback. callback should take two arguments: int mouse button index (one of MouseButton values) and Vector2i click position in screen coordinates.
Note: This method is implemented on macOS and Windows.
void status_indicator_set_icon(id: int, icon: Texture2D) 🔗
Sets the application status indicator icon.
Note: This method is implemented on macOS and Windows.
Sets the application status indicator native popup menu.
Note: On macOS, the menu is activated by any mouse button. Its activation callback is not triggered.
Note: On Windows, the menu is activated by the right mouse button, selecting the status icon and pressing Shift + F10, or the applications key. The menu's activation callback for the other mouse buttons is still triggered.
Note: Native popup is only supported if NativeMenu supports the NativeMenu.FEATURE_POPUP_MENU feature.
void status_indicator_set_tooltip(id: int, tooltip: String) 🔗
Sets the application status indicator tooltip.
Note: This method is implemented on macOS and Windows.
String tablet_get_current_driver() const 🔗
返回目前活動的數位板驅動程式的名稱。
注意:該方法僅在 Windows 上實作。
int tablet_get_driver_count() const 🔗
返回可用的數位板驅動程式的總數。
注意:該方法僅在 Windows 上實作。
String tablet_get_driver_name(idx: int) const 🔗
返回給定索引的數位板驅動程式名稱。
注意:該方法僅在 Windows 上實作。
void tablet_set_current_driver(name: String) 🔗
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.
Array[Dictionary] tts_get_voices() const 🔗
Returns an Array of voice information dictionaries.
Each Dictionary contains two String entries:
nameis voice name.idis voice identifier.languageis language code inlang_Variantformat. Thelangpart is a 2 or 3-letter code based on the ISO-639 standard, in lowercase. TheVariantpart 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.
PackedStringArray tts_get_voices_for_language(language: String) const 🔗
Returns a PackedStringArray of voice identifiers for the language.
Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.
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.
bool tts_is_speaking() const 🔗
Returns true if the synthesizer is generating speech, or have utterance waiting in the queue.
Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.
void tts_pause() 🔗
Puts the synthesizer into a paused state.
Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.
void tts_resume() 🔗
Resumes the synthesizer if it was paused.
Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.
void tts_set_utterance_callback(event: TTSUtteranceEvent, callable: Callable) 🔗
Adds a callback, which is called when the utterance has started, finished, canceled or reached a text boundary.
TTS_UTTERANCE_STARTED, TTS_UTTERANCE_ENDED, and TTS_UTTERANCE_CANCELED callable's method should take one int parameter, the utterance ID.
TTS_UTTERANCE_BOUNDARY callable's method should take two int parameters, the index of the character and the utterance ID.
Note: The granularity of the boundary callbacks is engine dependent.
Note: This method is implemented on Android, iOS, Web, Linux (X11/Wayland), macOS, and Windows.
void tts_speak(text: String, voice: String, volume: int = 50, pitch: float = 1.0, rate: float = 1.0, utterance_id: int = 0, interrupt: bool = false) 🔗
Adds an utterance to the queue. If interrupt is true, the queue is cleared first.
voiceidentifier is one of the"id"values returned by tts_get_voices() or one of the values returned by tts_get_voices_for_language().volumeranges from0(lowest) to100(highest).pitchranges from0.0(lowest) to2.0(highest),1.0is default pitch for the current voice.rateranges from0.1(lowest) to10.0(highest),1.0is a normal speaking rate. Other values act as a percentage relative.utterance_idis 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.
void tts_stop() 🔗
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.
void unregister_additional_output(object: Object) 🔗
Unregisters an Object representing an additional output, that was registered via register_additional_output().
int virtual_keyboard_get_height() const 🔗
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.
void virtual_keyboard_hide() 🔗
如果虛擬鍵盤為顯示狀態則隱藏虛擬鍵盤,否則不做任何操作。
void virtual_keyboard_show(existing_text: String, position: Rect2 = Rect2(0, 0, 0, 0), type: VirtualKeyboardType = 0, max_length: int = -1, cursor_start: int = -1, cursor_end: int = -1) 🔗
如果該平臺有虛擬鍵盤,則顯示虛擬鍵盤。
existing_text 參數對於實作你自己的 LineEdit 或 TextEdit 很有用,因為它告訴虛擬鍵盤已經輸入了哪些文字(虛擬鍵盤使用它進行自動校正和預測)。
position 參數為編輯文字的螢幕空間 Rect2。
type 參數允許配置要顯示的虛擬鍵盤型別。
max_length 在當與 -1 不同時,限制可輸入的字元數。
如果未設定 cursor_end,則可選參數 cursor_start 可以定義目前文本游標位置。
可選參數 cursor_start 和 cursor_end,可以定義目前文字選區。
注意:該方法在 Android、iOS 和 Web 上實作。
void warp_mouse(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.
bool window_can_draw(window_id: int = 0) const 🔗
如果可以在 window_id 指定的視窗中繪製任何內容,則返回 true,否則返回 false。使用 --disable-render-loop 命令列參數或無頭建構將返回 false。
int window_get_active_popup() const 🔗
返回活動快顯視窗的 ID,如果沒有則返回 INVALID_WINDOW_ID。
int window_get_attached_instance_id(window_id: int = 0) const 🔗
返回 window_id 所附加的 Window 的 Object.get_instance_id()。
int window_get_current_screen(window_id: int = 0) const 🔗
Returns the screen the window specified by window_id is currently positioned on. If the screen overlaps multiple displays, the screen where the window's center is located is returned. See also 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.
bool window_get_flag(flag: WindowFlags, window_id: int = 0) const 🔗
返回給定視窗目前的 flag 值。
float window_get_hdr_output_current_max_luminance(window_id: int = 0) const 🔗
實驗性: 此方法可能在未來版本中變更或移除。
When window_is_hdr_output_enabled() returns true, this returns the current maximum luminance in nits (cd/m²) for HDR output by the window specified by window_id. If the maximum luminance is being automatically adjusted based on the screen's capabilities, this method will return that value. Otherwise, it will return the value set by window_set_hdr_output_max_luminance(). This maximum luminance value is used when calculating window_get_output_max_linear_value().
Note: This maximum luminance may not match the physical behavior of the screen, but will always be proportionally correct relative to window_get_hdr_output_current_reference_luminance().
float window_get_hdr_output_current_reference_luminance(window_id: int = 0) const 🔗
When window_is_hdr_output_enabled() returns true, this returns the current reference white luminance in nits (cd/m²) for HDR output by the window specified by window_id. If the reference luminance is being automatically adjusted to match the operating system brightness, this will return that value. Otherwise, it will return the value set by window_set_hdr_output_reference_luminance(). This reference luminance value is used when calculating window_get_output_max_linear_value().
Note: This reference white luminance may not match the physical behavior of the screen, but will always be proportionally correct relative to window_get_hdr_output_current_max_luminance().
float window_get_hdr_output_max_luminance(window_id: int = 0) const 🔗
實驗性: 此方法可能在未來版本中變更或移除。
Returns the maximum luminance in nits (cd/m²) set for HDR output by the window specified by window_id. Negative values indicate that the value is being automatically adjusted based on the screen's capabilities. See also window_get_hdr_output_current_max_luminance().
float window_get_hdr_output_reference_luminance(window_id: int = 0) const 🔗
Returns the reference white luminance in nits (cd/m²) set for HDR output by the window specified by window_id. Negative values indicate that the value is being automatically adjusted to match the operating system brightness. See also window_get_hdr_output_current_reference_luminance().
Vector2i window_get_max_size(window_id: int = 0) const 🔗
返回該視窗的最大尺寸,單位為圖元。另見 window_set_max_size()。
Vector2i window_get_min_size(window_id: int = 0) const 🔗
返回該視窗的最小尺寸,單位為圖元。另見 window_set_min_size()。
WindowMode window_get_mode(window_id: int = 0) const 🔗
返回給定視窗的模式。
int window_get_native_handle(handle_type: HandleType, window_id: int = 0) const 🔗
Returns internal structure pointers for use in plugins.
Note: This method is implemented on Android, Linux (X11/Wayland), macOS, and Windows.
float window_get_output_max_linear_value(window_id: int = 0) const 🔗
Returns the maximum value for linear color components that can be displayed for the window specified by window_id, regardless of SDR or HDR output. Returns 1.0 if HDR is not enabled or not supported. When HDR output is enabled, this is calculated based on window_get_hdr_output_current_reference_luminance() and window_get_hdr_output_current_max_luminance(). The Window.output_max_linear_value_changed signal will be emitted whenever this value changes. This value is used by tonemapping and other Environment effects to ensure that bright colors are presented in the range that can be displayed by this window. Corresponds to Window.get_output_max_linear_value().
Rect2i window_get_popup_safe_rect(window: int) const 🔗
該函式返回控制項或功能表專案在螢幕坐標系統中的邊界框,這個控制項或功能表專案被用來打開彈出視窗。
Vector2i window_get_position(window_id: int = 0) const 🔗
返回螢幕上給定視窗的使用者端區域位置。
Vector2i window_get_position_with_decorations(window_id: int = 0) const 🔗
該函式返回給定視窗在螢幕上的位置,包括作業系統繪製的邊框。另見 window_get_position()。
Vector3i window_get_safe_title_margins(window_id: int = 0) const 🔗
當設定了 WINDOW_FLAG_EXTEND_TO_TITLE 旗標時,該函式返回標題左邊距 (x)、右邊距 (y) 和高度 (z),這些邊距可以安全地使用(不包含任何按鈕或其他元素)。
Vector2i window_get_size(window_id: int = 0) const 🔗
返回視窗的大小(單位為圖元),不包含作業系統繪製的邊框,該視窗由 window_id 指定。這個區域也叫做“使用者端區域”。另見 window_get_size_with_decorations()、window_set_size()、window_get_position()。
Vector2i window_get_size_with_decorations(window_id: int = 0) const 🔗
返回視窗的大小(單位為圖元),包含作業系統繪製的邊框,該視窗由 window_id 指定。另見 window_get_size()。
Vector2i window_get_title_size(title: String, window_id: int = 0) const 🔗
Returns the estimated window title bar size (including text and window buttons) for the window specified by window_id (in pixels). This method does not change the window title.
Note: This method is implemented on macOS and Windows.
VSyncMode window_get_vsync_mode(window_id: int = 0) const 🔗
返回給定視窗的垂直同步模式。
bool window_is_focused(window_id: int = 0) const 🔗
如果 window_id 指定的視窗已獲得焦點,則返回 true。
bool window_is_hdr_output_enabled(window_id: int = 0) const 🔗
Returns true if HDR output is currently enabled for the window specified by window_id. The returned value may change dynamically based on system settings, screen capabilities, and which screen the window is currently on.
bool window_is_hdr_output_requested(window_id: int = 0) const 🔗
Returns true if HDR output is requested for the window specified by window_id. Corresponds to Window.hdr_output_requested.
bool window_is_hdr_output_supported(window_id: int = 0) const 🔗
Returns true if the window specified by window_id supports HDR output. This depends on the platform, screen capabilities, system settings, and the screen the window is currently on.
bool window_is_maximize_allowed(window_id: int = 0) const 🔗
如果給定的視窗能夠最大化(最大化按鈕已啟用),則返回 true。
bool window_maximize_on_title_dbl_click() const 🔗
Returns true if double-clicking on a window's title should maximize it.
Note: This method is implemented only on macOS.
bool window_minimize_on_title_dbl_click() const 🔗
Returns true if double-clicking on a window's title should minimize it.
Note: This method is implemented only on macOS.
void window_move_to_foreground(window_id: int = 0) 🔗
將由 window_id 指定的視窗移動至前臺,使其位於其他視窗之上。
void window_request_attention(window_id: int = 0) 🔗
讓由 window_id 指定的視窗請求注意,該視窗獲得焦點之前會閃爍視窗標題和工作列專案。如果該視窗目前持有焦點,則通常是沒有可見效果的。實際的行為因操作系統而異。
void window_request_hdr_output(enable: bool, window_id: int = 0) 🔗
If enable is true, HDR output is requested for the window specified by window_id. The window will automatically switch between HDR and SDR if it is moved between screens, screen capabilities change, or system settings are modified. This will internally force Viewport.use_hdr_2d to be enabled on the main Viewport. All other SubViewport of the Window must have their Viewport.use_hdr_2d property enabled to produce HDR output. Corresponds to Window.hdr_output_requested.
void window_set_color(color: Color) 🔗
Sets the background color of the root window.
Note: This method is implemented only on Android.
void window_set_current_screen(screen: int, window_id: int = 0) 🔗
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.
void window_set_drop_files_callback(callback: Callable, window_id: int = 0) 🔗
Sets the callback that should be called when files are dropped from the operating system's file manager to the window specified by window_id. callback should take one PackedStringArray argument, which is the list of dropped files.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
Note: This method is implemented on Windows, macOS, Linux (X11/Wayland), and Web.
void window_set_exclusive(window_id: int, exclusive: bool) 🔗
如果設定為 true,該視窗將始終位於其父視窗之上,父視窗將在該視窗打開時忽略輸入。
注意:在 macOS 上,獨佔視窗被限制在與父視窗相同的空間(虛擬桌面或屏幕)中。
注意:該方法在 macOS 和 Windows 上實作。
void window_set_flag(flag: WindowFlags, enabled: bool, window_id: int = 0) 🔗
Enables or disables the given window's given flag.
void window_set_hdr_output_max_luminance(max_luminance: float, window_id: int = 0) 🔗
實驗性: 此方法可能在未來版本中變更或移除。
Sets the maximum luminance in nits (cd/m²) for HDR output by the window specified by window_id. If max_luminance is negative, the window uses the screen's maximum luminance that is reported by the operating system. By default, this luminance is set to -1.0 for every window. Typically this property should be left at this default value, but may optionally be exposed through in-game settings to allow the player to correct an inaccurate maximum luminance reported by the operating system. See also window_get_hdr_output_current_max_luminance() and window_get_hdr_output_max_luminance().
Note: This method is only implemented on macOS and Windows. Other platforms will always use the screen's maximum luminance that is reported by the operating system.
void window_set_hdr_output_reference_luminance(reference_luminance: float, window_id: int = 0) 🔗
Sets the reference white luminance in nits (cd/m²) for HDR output by the window specified by window_id. If reference_luminance is negative, the window automatically adjusts to the brightness set by the operating system. By default, this luminance is set to -1.0 for every window. Typically this property should be left at this default value, but may optionally be exposed as an "HDR Brightness" in-game setting to allow the player to adjust the brightness of their game, independently of their device settings. See also window_get_hdr_output_current_reference_luminance() and window_get_hdr_output_reference_luminance().
Note: This method is only implemented on Windows. Other platforms will always use the reference luminance that is reported by the operating system.
void window_set_icon(icon: Image, window_id: int = 0) 🔗
Sets the window icon (usually displayed in the top-left corner) for the window specified by window_id.
Note: This method is implemented on Linux and Windows.
void window_set_ime_active(active: bool, window_id: int = 0) 🔗
設定是否應該為視窗啟用輸入法編輯器,該視窗由 window_id 指定。另見 window_set_ime_position()。
void window_set_ime_position(position: Vector2i, window_id: int = 0) 🔗
設定指定 window_id 的輸入法編輯器彈出框的位置。僅在指定 window_id 的 window_set_ime_active() 為 true 時有效。
void window_set_input_event_callback(callback: Callable, window_id: int = 0) 🔗
Sets the callback that should be called when any InputEvent is sent to the window specified by window_id.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
void window_set_input_text_callback(callback: Callable, window_id: int = 0) 🔗
Sets the callback that should be called when text is entered using the virtual keyboard to the window specified by window_id.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
void window_set_max_size(max_size: Vector2i, window_id: int = 0) 🔗
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 Window.max_size instead.
Note: Using third-party tools, it is possible for users to disable window geometry restrictions and therefore bypass this limit.
void window_set_min_size(min_size: Vector2i, window_id: int = 0) 🔗
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 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.
void window_set_mode(mode: WindowMode, window_id: int = 0) 🔗
Sets window mode for the given window to mode.
Note: On Android, setting it to WINDOW_MODE_FULLSCREEN or WINDOW_MODE_EXCLUSIVE_FULLSCREEN will enable immersive mode.
Note: Setting the window to full screen forcibly sets the borderless flag to true, so make sure to set it back to false when not wanted.
void window_set_mouse_passthrough(region: PackedVector2Array, window_id: int = 0) 🔗
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([])
// Set region, using Path2D node.
DisplayServer.WindowSetMousePassthrough(GetNode<Path2D>("Path2D").Curve.GetBakedPoints());
// Set region, using Polygon2D node.
DisplayServer.WindowSetMousePassthrough(GetNode<Polygon2D>("Polygon2D").Polygon);
// Reset region to default.
DisplayServer.WindowSetMousePassthrough([]);
Note: On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is.
Note: This method is implemented on Linux (X11), macOS and Windows.
void window_set_popup_safe_rect(window: int, rect: Rect2i) 🔗
設定用於打開快顯視窗的控制項或功能表專案的範圍框,使用螢幕坐標系。在該區域中點擊不會自動關閉該彈出框。
void window_set_position(position: Vector2i, window_id: int = 0) 🔗
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 Window.position instead.
Note: On Linux (Wayland): this method is a no-op.
void window_set_rect_changed_callback(callback: Callable, window_id: int = 0) 🔗
Sets the callback that will be called when the window specified by window_id is moved or resized.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
void window_set_size(size: Vector2i, window_id: int = 0) 🔗
將給定視窗的大小設定為 size(單位為圖元)。另見 window_get_size() 和 window_get_position()。
注意:建議改用 Window.size 更改此值。
void window_set_taskbar_progress_state(state: ProgressState, window_id: int = 0) 🔗
Sets the type and state of the progress bar on the taskbar/dock icon of the window specified by window_id. See ProgressState for possible values and how each mode behaves.
Note: This method is implemented only on Windows and macOS.
Note: On macOS, the progress bar is displayed only for the main window.
void window_set_taskbar_progress_value(value: float, window_id: int = 0) 🔗
Creates a progress bar on the taskbar/dock icon of the window specified by window_id if it does not exist, sets the progress of the icon.
value acts as a relative percentage value, ranges from 0.0 (lowest) to 1.0 (highest).
Note: This method is implemented only on Windows and macOS.
Note: On macOS, the progress bar is displayed only for the main window.
void window_set_title(title: String, window_id: int = 0) 🔗
將給定視窗的標題設定為 title。
注意:建議改用 Window.title 更改此值。
注意:避免每一影格都更改視窗標題,因為這會導致某些視窗管理器出現性能問題。嘗試每秒最多更改幾次視窗標題。
void window_set_transient(window_id: int, parent_window_id: int) 🔗
Sets window transient parent. Transient window will be destroyed with its transient parent and will return focus to their parent when closed. The transient window is displayed on top of a non-exclusive full-screen parent window. Transient windows can't enter full-screen mode.
Note: It's recommended to change this value using Window.transient instead.
Note: The behavior might be different depending on the platform.
void window_set_vsync_mode(vsync_mode: VSyncMode, window_id: int = 0) 🔗
Sets the V-Sync mode of the given window. See also ProjectSettings.display/window/vsync/vsync_mode.
Depending on the platform and used renderer, the engine will fall back to VSYNC_ENABLED if the desired mode is not supported.
Note: V-Sync modes other than VSYNC_ENABLED are only supported in the Forward+ and Mobile rendering methods, not Compatibility.
void window_set_window_buttons_offset(offset: Vector2i, window_id: int = 0) 🔗
設定了 WINDOW_FLAG_EXTEND_TO_TITLE 旗標時,會設定第一個標題列按鈕中心的偏移量。
注意:這個旗標僅在 macOS 上實作。
void window_set_window_event_callback(callback: Callable, window_id: int = 0) 🔗
Sets the callback that will be called when an event occurs in the window specified by window_id.
Warning: Advanced users only! Adding such a callback to a Window node will override its default implementation, which can introduce bugs.
void window_start_drag(window_id: int = 0) 🔗
Starts an interactive drag operation on the window with the given window_id, using the current mouse position. Call this method when handling a mouse button being pressed to simulate a pressed event on the window's title bar. Using this method allows the window to participate in space switching, tiling, and other system features.
Note: This method is implemented on Linux (X11/Wayland), macOS, and Windows.
void window_start_resize(edge: WindowResizeEdge, window_id: int = 0) 🔗
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.