| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="NativeMenu" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A server interface for OS native menus. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | [NativeMenu] handles low-level access to the OS native global menu bar and popup menus. |
| 8 | [b]Note:[/b] This is low-level API, consider using [MenuBar] with [member MenuBar.prefer_global_menu] set to [code]true[/code], and [PopupMenu] with [member PopupMenu.prefer_native_menu] set to [code]true[/code]. |
| 9 | To create a menu, use [method create_menu], add menu items using [code]add_*_item[/code] methods. To remove a menu, use [method free_menu]. |
| 10 | [codeblock] |
| 11 | var menu |
| 12 | |
| 13 | func _menu_callback(item_id): |
| 14 | if item_id == "ITEM_CUT": |
| 15 | cut() |
| 16 | elif item_id == "ITEM_COPY": |
| 17 | copy() |
| 18 | elif item_id == "ITEM_PASTE": |
| 19 | paste() |
| 20 | |
| 21 | func _enter_tree(): |
| 22 | # Create new menu and add items: |
| 23 | menu = NativeMenu.create_menu() |
| 24 | NativeMenu.add_item(menu, "Cut", _menu_callback, Callable(), "ITEM_CUT") |
| 25 | NativeMenu.add_item(menu, "Copy", _menu_callback, Callable(), "ITEM_COPY") |
| 26 | NativeMenu.add_separator(menu) |
| 27 | NativeMenu.add_item(menu, "Paste", _menu_callback, Callable(), "ITEM_PASTE") |
| 28 | |
| 29 | func _on_button_pressed(): |
| 30 | # Show popup menu at mouse position: |
| 31 | NativeMenu.popup(menu, DisplayServer.mouse_get_position()) |
| 32 | |
| 33 | func _exit_tree(): |
| 34 | # Remove menu when it's no longer needed: |
| 35 | NativeMenu.free_menu(menu) |
| 36 | [/codeblock] |
| 37 | </description> |
| 38 | <tutorials> |
| 39 | </tutorials> |
| 40 | <methods> |
| 41 | <method name="add_check_item"> |
| 42 | <return type="int" /> |
| 43 | <param index="0" name="rid" type="RID" /> |
| 44 | <param index="1" name="label" type="String" /> |
| 45 | <param index="2" name="callback" type="Callable" default="Callable()" /> |
| 46 | <param index="3" name="key_callback" type="Callable" default="Callable()" /> |
| 47 | <param index="4" name="tag" type="Variant" default="null" /> |
| 48 | <param index="5" name="accelerator" type="int" enum="Key" default="0" /> |
| 49 | <param index="6" name="index" type="int" default="-1" /> |
| 50 | <description> |
| 51 | Adds a new checkable item with text [param label] to the global menu [param rid]. |
| 52 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 53 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 54 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 55 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 56 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 57 | </description> |
| 58 | </method> |
| 59 | <method name="add_icon_check_item"> |
| 60 | <return type="int" /> |
| 61 | <param index="0" name="rid" type="RID" /> |
| 62 | <param index="1" name="icon" type="Texture2D" /> |
| 63 | <param index="2" name="label" type="String" /> |
| 64 | <param index="3" name="callback" type="Callable" default="Callable()" /> |
| 65 | <param index="4" name="key_callback" type="Callable" default="Callable()" /> |
| 66 | <param index="5" name="tag" type="Variant" default="null" /> |
| 67 | <param index="6" name="accelerator" type="int" enum="Key" default="0" /> |
| 68 | <param index="7" name="index" type="int" default="-1" /> |
| 69 | <description> |
| 70 | Adds a new checkable item with text [param label] and icon [param icon] to the global menu [param rid]. |
| 71 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 72 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 73 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 74 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 75 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 76 | </description> |
| 77 | </method> |
| 78 | <method name="add_icon_item"> |
| 79 | <return type="int" /> |
| 80 | <param index="0" name="rid" type="RID" /> |
| 81 | <param index="1" name="icon" type="Texture2D" /> |
| 82 | <param index="2" name="label" type="String" /> |
| 83 | <param index="3" name="callback" type="Callable" default="Callable()" /> |
| 84 | <param index="4" name="key_callback" type="Callable" default="Callable()" /> |
| 85 | <param index="5" name="tag" type="Variant" default="null" /> |
| 86 | <param index="6" name="accelerator" type="int" enum="Key" default="0" /> |
| 87 | <param index="7" name="index" type="int" default="-1" /> |
| 88 | <description> |
| 89 | Adds a new item with text [param label] and icon [param icon] to the global menu [param rid]. |
| 90 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 91 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 92 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 93 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 94 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 95 | </description> |
| 96 | </method> |
| 97 | <method name="add_icon_radio_check_item"> |
| 98 | <return type="int" /> |
| 99 | <param index="0" name="rid" type="RID" /> |
| 100 | <param index="1" name="icon" type="Texture2D" /> |
| 101 | <param index="2" name="label" type="String" /> |
| 102 | <param index="3" name="callback" type="Callable" default="Callable()" /> |
| 103 | <param index="4" name="key_callback" type="Callable" default="Callable()" /> |
| 104 | <param index="5" name="tag" type="Variant" default="null" /> |
| 105 | <param index="6" name="accelerator" type="int" enum="Key" default="0" /> |
| 106 | <param index="7" name="index" type="int" default="-1" /> |
| 107 | <description> |
| 108 | Adds a new radio-checkable item with text [param label] and icon [param icon] to the global menu [param rid]. |
| 109 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 110 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 111 | [b]Note:[/b] Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it. |
| 112 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 113 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 114 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 115 | </description> |
| 116 | </method> |
| 117 | <method name="add_item"> |
| 118 | <return type="int" /> |
| 119 | <param index="0" name="rid" type="RID" /> |
| 120 | <param index="1" name="label" type="String" /> |
| 121 | <param index="2" name="callback" type="Callable" default="Callable()" /> |
| 122 | <param index="3" name="key_callback" type="Callable" default="Callable()" /> |
| 123 | <param index="4" name="tag" type="Variant" default="null" /> |
| 124 | <param index="5" name="accelerator" type="int" enum="Key" default="0" /> |
| 125 | <param index="6" name="index" type="int" default="-1" /> |
| 126 | <description> |
| 127 | Adds a new item with text [param label] to the global menu [param rid]. |
| 128 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 129 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 130 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 131 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 132 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 133 | </description> |
| 134 | </method> |
| 135 | <method name="add_multistate_item"> |
| 136 | <return type="int" /> |
| 137 | <param index="0" name="rid" type="RID" /> |
| 138 | <param index="1" name="label" type="String" /> |
| 139 | <param index="2" name="max_states" type="int" /> |
| 140 | <param index="3" name="default_state" type="int" /> |
| 141 | <param index="4" name="callback" type="Callable" default="Callable()" /> |
| 142 | <param index="5" name="key_callback" type="Callable" default="Callable()" /> |
| 143 | <param index="6" name="tag" type="Variant" default="null" /> |
| 144 | <param index="7" name="accelerator" type="int" enum="Key" default="0" /> |
| 145 | <param index="8" name="index" type="int" default="-1" /> |
| 146 | <description> |
| 147 | Adds a new item with text [param label] to the global menu [param rid]. |
| 148 | Contrarily to normal binary items, multistate items can have more than two states, as defined by [param max_states]. Each press or activate of the item will increase the state by one. The default value is defined by [param default_state]. |
| 149 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 150 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 151 | [b]Note:[/b] By default, there's no indication of the current item state, it should be changed manually. |
| 152 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 153 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 154 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 155 | </description> |
| 156 | </method> |
| 157 | <method name="add_radio_check_item"> |
| 158 | <return type="int" /> |
| 159 | <param index="0" name="rid" type="RID" /> |
| 160 | <param index="1" name="label" type="String" /> |
| 161 | <param index="2" name="callback" type="Callable" default="Callable()" /> |
| 162 | <param index="3" name="key_callback" type="Callable" default="Callable()" /> |
| 163 | <param index="4" name="tag" type="Variant" default="null" /> |
| 164 | <param index="5" name="accelerator" type="int" enum="Key" default="0" /> |
| 165 | <param index="6" name="index" type="int" default="-1" /> |
| 166 | <description> |
| 167 | Adds a new radio-checkable item with text [param label] to the global menu [param rid]. |
| 168 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 169 | An [param 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 [param accelerator] is generally a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 170 | [b]Note:[/b] Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it. |
| 171 | [b]Note:[/b] The [param callback] and [param key_callback] Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to [param tag]. |
| 172 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 173 | [b]Note:[/b] On Windows, [param accelerator] and [param key_callback] are ignored. |
| 174 | </description> |
| 175 | </method> |
| 176 | <method name="add_separator"> |
| 177 | <return type="int" /> |
| 178 | <param index="0" name="rid" type="RID" /> |
| 179 | <param index="1" name="index" type="int" default="-1" /> |
| 180 | <description> |
| 181 | Adds a separator between items to the global menu [param rid]. Separators also occupy an index. |
| 182 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 183 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 184 | </description> |
| 185 | </method> |
| 186 | <method name="add_submenu_item"> |
| 187 | <return type="int" /> |
| 188 | <param index="0" name="rid" type="RID" /> |
| 189 | <param index="1" name="label" type="String" /> |
| 190 | <param index="2" name="submenu_rid" type="RID" /> |
| 191 | <param index="3" name="tag" type="Variant" default="null" /> |
| 192 | <param index="4" name="index" type="int" default="-1" /> |
| 193 | <description> |
| 194 | Adds an item that will act as a submenu of the global menu [param rid]. The [param submenu_rid] argument is the RID of the global menu that will be shown when the item is clicked. |
| 195 | Returns index of the inserted item, it's not guaranteed to be the same as [param index] value. |
| 196 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 197 | </description> |
| 198 | </method> |
| 199 | <method name="clear"> |
| 200 | <return type="void" /> |
| 201 | <param index="0" name="rid" type="RID" /> |
| 202 | <description> |
| 203 | Removes all items from the global menu [param rid]. |
| 204 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 205 | </description> |
| 206 | </method> |
| 207 | <method name="create_menu"> |
| 208 | <return type="RID" /> |
| 209 | <description> |
| 210 | Creates a new global menu object. |
| 211 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 212 | </description> |
| 213 | </method> |
| 214 | <method name="find_item_index_with_submenu" qualifiers="const"> |
| 215 | <return type="int" /> |
| 216 | <param index="0" name="rid" type="RID" /> |
| 217 | <param index="1" name="submenu_rid" type="RID" /> |
| 218 | <description> |
| 219 | Returns the index of the item with the submenu specified by [param submenu_rid]. Indices are automatically assigned to each item by the engine, and cannot be set manually. |
| 220 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 221 | </description> |
| 222 | </method> |
| 223 | <method name="find_item_index_with_tag" qualifiers="const"> |
| 224 | <return type="int" /> |
| 225 | <param index="0" name="rid" type="RID" /> |
| 226 | <param index="1" name="tag" type="Variant" /> |
| 227 | <description> |
| 228 | Returns the index of the item with the specified [param tag]. Indices are automatically assigned to each item by the engine, and cannot be set manually. |
| 229 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 230 | </description> |
| 231 | </method> |
| 232 | <method name="find_item_index_with_text" qualifiers="const"> |
| 233 | <return type="int" /> |
| 234 | <param index="0" name="rid" type="RID" /> |
| 235 | <param index="1" name="text" type="String" /> |
| 236 | <description> |
| 237 | Returns the index of the item with the specified [param text]. Indices are automatically assigned to each item by the engine, and cannot be set manually. |
| 238 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 239 | </description> |
| 240 | </method> |
| 241 | <method name="free_menu"> |
| 242 | <return type="void" /> |
| 243 | <param index="0" name="rid" type="RID" /> |
| 244 | <description> |
| 245 | Frees a global menu object created by this [NativeMenu]. |
| 246 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 247 | </description> |
| 248 | </method> |
| 249 | <method name="get_item_accelerator" qualifiers="const"> |
| 250 | <return type="int" enum="Key" /> |
| 251 | <param index="0" name="rid" type="RID" /> |
| 252 | <param index="1" name="idx" type="int" /> |
| 253 | <description> |
| 254 | Returns the accelerator of the item at index [param idx]. Accelerators are special combinations of keys that activate the item, no matter which control is focused. |
| 255 | [b]Note:[/b] This method is implemented only on macOS. |
| 256 | </description> |
| 257 | </method> |
| 258 | <method name="get_item_callback" qualifiers="const"> |
| 259 | <return type="Callable" /> |
| 260 | <param index="0" name="rid" type="RID" /> |
| 261 | <param index="1" name="idx" type="int" /> |
| 262 | <description> |
| 263 | Returns the callback of the item at index [param idx]. |
| 264 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 265 | </description> |
| 266 | </method> |
| 267 | <method name="get_item_count" qualifiers="const"> |
| 268 | <return type="int" /> |
| 269 | <param index="0" name="rid" type="RID" /> |
| 270 | <description> |
| 271 | Returns number of items in the global menu [param rid]. |
| 272 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 273 | </description> |
| 274 | </method> |
| 275 | <method name="get_item_icon" qualifiers="const"> |
| 276 | <return type="Texture2D" /> |
| 277 | <param index="0" name="rid" type="RID" /> |
| 278 | <param index="1" name="idx" type="int" /> |
| 279 | <description> |
| 280 | Returns the icon of the item at index [param idx]. |
| 281 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 282 | </description> |
| 283 | </method> |
| 284 | <method name="get_item_indentation_level" qualifiers="const"> |
| 285 | <return type="int" /> |
| 286 | <param index="0" name="rid" type="RID" /> |
| 287 | <param index="1" name="idx" type="int" /> |
| 288 | <description> |
| 289 | Returns the horizontal offset of the item at the given [param idx]. |
| 290 | [b]Note:[/b] This method is implemented only on macOS. |
| 291 | </description> |
| 292 | </method> |
| 293 | <method name="get_item_key_callback" qualifiers="const"> |
| 294 | <return type="Callable" /> |
| 295 | <param index="0" name="rid" type="RID" /> |
| 296 | <param index="1" name="idx" type="int" /> |
| 297 | <description> |
| 298 | Returns the callback of the item accelerator at index [param idx]. |
| 299 | [b]Note:[/b] This method is implemented only on macOS. |
| 300 | </description> |
| 301 | </method> |
| 302 | <method name="get_item_max_states" qualifiers="const"> |
| 303 | <return type="int" /> |
| 304 | <param index="0" name="rid" type="RID" /> |
| 305 | <param index="1" name="idx" type="int" /> |
| 306 | <description> |
| 307 | Returns number of states of a multistate item. See [method add_multistate_item] for details. |
| 308 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 309 | </description> |
| 310 | </method> |
| 311 | <method name="get_item_state" qualifiers="const"> |
| 312 | <return type="int" /> |
| 313 | <param index="0" name="rid" type="RID" /> |
| 314 | <param index="1" name="idx" type="int" /> |
| 315 | <description> |
| 316 | Returns the state of a multistate item. See [method add_multistate_item] for details. |
| 317 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 318 | </description> |
| 319 | </method> |
| 320 | <method name="get_item_submenu" qualifiers="const"> |
| 321 | <return type="RID" /> |
| 322 | <param index="0" name="rid" type="RID" /> |
| 323 | <param index="1" name="idx" type="int" /> |
| 324 | <description> |
| 325 | Returns the submenu ID of the item at index [param idx]. See [method add_submenu_item] for more info on how to add a submenu. |
| 326 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 327 | </description> |
| 328 | </method> |
| 329 | <method name="get_item_tag" qualifiers="const"> |
| 330 | <return type="Variant" /> |
| 331 | <param index="0" name="rid" type="RID" /> |
| 332 | <param index="1" name="idx" type="int" /> |
| 333 | <description> |
| 334 | Returns the metadata of the specified item, which might be of any type. You can set it with [method set_item_tag], which provides a simple way of assigning context data to items. |
| 335 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 336 | </description> |
| 337 | </method> |
| 338 | <method name="get_item_text" qualifiers="const"> |
| 339 | <return type="String" /> |
| 340 | <param index="0" name="rid" type="RID" /> |
| 341 | <param index="1" name="idx" type="int" /> |
| 342 | <description> |
| 343 | Returns the text of the item at index [param idx]. |
| 344 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 345 | </description> |
| 346 | </method> |
| 347 | <method name="get_item_tooltip" qualifiers="const"> |
| 348 | <return type="String" /> |
| 349 | <param index="0" name="rid" type="RID" /> |
| 350 | <param index="1" name="idx" type="int" /> |
| 351 | <description> |
| 352 | Returns the tooltip associated with the specified index [param idx]. |
| 353 | [b]Note:[/b] This method is implemented only on macOS. |
| 354 | </description> |
| 355 | </method> |
| 356 | <method name="get_minimum_width" qualifiers="const"> |
| 357 | <return type="float" /> |
| 358 | <param index="0" name="rid" type="RID" /> |
| 359 | <description> |
| 360 | Returns global menu minimum width. |
| 361 | [b]Note:[/b] This method is implemented only on macOS. |
| 362 | </description> |
| 363 | </method> |
| 364 | <method name="get_popup_close_callback" qualifiers="const"> |
| 365 | <return type="Callable" /> |
| 366 | <param index="0" name="rid" type="RID" /> |
| 367 | <description> |
| 368 | Returns global menu close callback. |
| 369 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 370 | </description> |
| 371 | </method> |
| 372 | <method name="get_popup_open_callback" qualifiers="const"> |
| 373 | <return type="Callable" /> |
| 374 | <param index="0" name="rid" type="RID" /> |
| 375 | <description> |
| 376 | Returns global menu open callback. |
| 377 | [b]Note:[/b] This method is implemented only on macOS. |
| 378 | </description> |
| 379 | </method> |
| 380 | <method name="get_size" qualifiers="const"> |
| 381 | <return type="Vector2" /> |
| 382 | <param index="0" name="rid" type="RID" /> |
| 383 | <description> |
| 384 | Returns global menu size. |
| 385 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 386 | </description> |
| 387 | </method> |
| 388 | <method name="get_system_menu" qualifiers="const"> |
| 389 | <return type="RID" /> |
| 390 | <param index="0" name="menu_id" type="int" enum="NativeMenu.SystemMenus" /> |
| 391 | <description> |
| 392 | Returns RID of a special system menu. |
| 393 | [b]Note:[/b] This method is implemented only on macOS. |
| 394 | </description> |
| 395 | </method> |
| 396 | <method name="get_system_menu_name" qualifiers="const"> |
| 397 | <return type="String" /> |
| 398 | <param index="0" name="menu_id" type="int" enum="NativeMenu.SystemMenus" /> |
| 399 | <description> |
| 400 | Returns readable name of a special system menu. |
| 401 | [b]Note:[/b] This method is implemented only on macOS. |
| 402 | </description> |
| 403 | </method> |
| 404 | <method name="get_system_menu_text" qualifiers="const"> |
| 405 | <return type="String" /> |
| 406 | <param index="0" name="menu_id" type="int" enum="NativeMenu.SystemMenus" /> |
| 407 | <description> |
| 408 | Returns the text of the system menu item. |
| 409 | [b]Note:[/b] This method is implemented on macOS. |
| 410 | </description> |
| 411 | </method> |
| 412 | <method name="has_feature" qualifiers="const"> |
| 413 | <return type="bool" /> |
| 414 | <param index="0" name="feature" type="int" enum="NativeMenu.Feature" /> |
| 415 | <description> |
| 416 | Returns [code]true[/code] if the specified [param feature] is supported by the current [NativeMenu], [code]false[/code] otherwise. |
| 417 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 418 | </description> |
| 419 | </method> |
| 420 | <method name="has_menu" qualifiers="const"> |
| 421 | <return type="bool" /> |
| 422 | <param index="0" name="rid" type="RID" /> |
| 423 | <description> |
| 424 | Returns [code]true[/code] if [param rid] is valid global menu. |
| 425 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 426 | </description> |
| 427 | </method> |
| 428 | <method name="has_system_menu" qualifiers="const"> |
| 429 | <return type="bool" /> |
| 430 | <param index="0" name="menu_id" type="int" enum="NativeMenu.SystemMenus" /> |
| 431 | <description> |
| 432 | Returns [code]true[/code] if a special system menu is supported. |
| 433 | [b]Note:[/b] This method is implemented only on macOS. |
| 434 | </description> |
| 435 | </method> |
| 436 | <method name="is_item_checkable" qualifiers="const"> |
| 437 | <return type="bool" /> |
| 438 | <param index="0" name="rid" type="RID" /> |
| 439 | <param index="1" name="idx" type="int" /> |
| 440 | <description> |
| 441 | Returns [code]true[/code] if the item at index [param idx] is checkable in some way, i.e. if it has a checkbox or radio button. |
| 442 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 443 | </description> |
| 444 | </method> |
| 445 | <method name="is_item_checked" qualifiers="const"> |
| 446 | <return type="bool" /> |
| 447 | <param index="0" name="rid" type="RID" /> |
| 448 | <param index="1" name="idx" type="int" /> |
| 449 | <description> |
| 450 | Returns [code]true[/code] if the item at index [param idx] is checked. |
| 451 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 452 | </description> |
| 453 | </method> |
| 454 | <method name="is_item_disabled" qualifiers="const"> |
| 455 | <return type="bool" /> |
| 456 | <param index="0" name="rid" type="RID" /> |
| 457 | <param index="1" name="idx" type="int" /> |
| 458 | <description> |
| 459 | Returns [code]true[/code] if the item at index [param idx] is disabled. When it is disabled it can't be selected, or its action invoked. |
| 460 | See [method set_item_disabled] for more info on how to disable an item. |
| 461 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 462 | </description> |
| 463 | </method> |
| 464 | <method name="is_item_hidden" qualifiers="const"> |
| 465 | <return type="bool" /> |
| 466 | <param index="0" name="rid" type="RID" /> |
| 467 | <param index="1" name="idx" type="int" /> |
| 468 | <description> |
| 469 | Returns [code]true[/code] if the item at index [param idx] is hidden. |
| 470 | See [method set_item_hidden] for more info on how to hide an item. |
| 471 | [b]Note:[/b] This method is implemented only on macOS. |
| 472 | </description> |
| 473 | </method> |
| 474 | <method name="is_item_radio_checkable" qualifiers="const"> |
| 475 | <return type="bool" /> |
| 476 | <param index="0" name="rid" type="RID" /> |
| 477 | <param index="1" name="idx" type="int" /> |
| 478 | <description> |
| 479 | Returns [code]true[/code] if the item at index [param idx] has radio button-style checkability. |
| 480 | [b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups. |
| 481 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 482 | </description> |
| 483 | </method> |
| 484 | <method name="is_opened" qualifiers="const"> |
| 485 | <return type="bool" /> |
| 486 | <param index="0" name="rid" type="RID" /> |
| 487 | <description> |
| 488 | Returns [code]true[/code] if the menu is currently opened. |
| 489 | [b]Note:[/b] This method is implemented only on macOS. |
| 490 | </description> |
| 491 | </method> |
| 492 | <method name="is_system_menu" qualifiers="const"> |
| 493 | <return type="bool" /> |
| 494 | <param index="0" name="rid" type="RID" /> |
| 495 | <description> |
| 496 | Return [code]true[/code] is global menu is a special system menu. |
| 497 | [b]Note:[/b] This method is implemented only on macOS. |
| 498 | </description> |
| 499 | </method> |
| 500 | <method name="popup"> |
| 501 | <return type="void" /> |
| 502 | <param index="0" name="rid" type="RID" /> |
| 503 | <param index="1" name="position" type="Vector2i" /> |
| 504 | <description> |
| 505 | Shows the global menu at [param position] in the screen coordinates. |
| 506 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 507 | </description> |
| 508 | </method> |
| 509 | <method name="remove_item"> |
| 510 | <return type="void" /> |
| 511 | <param index="0" name="rid" type="RID" /> |
| 512 | <param index="1" name="idx" type="int" /> |
| 513 | <description> |
| 514 | Removes the item at index [param idx] from the global menu [param rid]. |
| 515 | [b]Note:[/b] The indices of items after the removed item will be shifted by one. |
| 516 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 517 | </description> |
| 518 | </method> |
| 519 | <method name="set_interface_direction"> |
| 520 | <return type="void" /> |
| 521 | <param index="0" name="rid" type="RID" /> |
| 522 | <param index="1" name="is_rtl" type="bool" /> |
| 523 | <description> |
| 524 | Sets the menu text layout direction from right-to-left if [param is_rtl] is [code]true[/code]. |
| 525 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 526 | </description> |
| 527 | </method> |
| 528 | <method name="set_item_accelerator"> |
| 529 | <return type="void" /> |
| 530 | <param index="0" name="rid" type="RID" /> |
| 531 | <param index="1" name="idx" type="int" /> |
| 532 | <param index="2" name="keycode" type="int" enum="Key" /> |
| 533 | <description> |
| 534 | Sets the accelerator of the item at index [param idx]. [param keycode] can be a single [enum Key], or a combination of [enum KeyModifierMask]s and [enum Key]s using bitwise OR such as [code]KEY_MASK_CTRL | KEY_A[/code] ([kbd]Ctrl + A[/kbd]). |
| 535 | [b]Note:[/b] This method is implemented only on macOS. |
| 536 | </description> |
| 537 | </method> |
| 538 | <method name="set_item_callback"> |
| 539 | <return type="void" /> |
| 540 | <param index="0" name="rid" type="RID" /> |
| 541 | <param index="1" name="idx" type="int" /> |
| 542 | <param index="2" name="callback" type="Callable" /> |
| 543 | <description> |
| 544 | Sets the callback of the item at index [param idx]. Callback is emitted when an item is pressed. |
| 545 | [b]Note:[/b] The [param callback] Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the [code]tag[/code] parameter when the menu item was created. |
| 546 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 547 | </description> |
| 548 | </method> |
| 549 | <method name="set_item_checkable"> |
| 550 | <return type="void" /> |
| 551 | <param index="0" name="rid" type="RID" /> |
| 552 | <param index="1" name="idx" type="int" /> |
| 553 | <param index="2" name="checkable" type="bool" /> |
| 554 | <description> |
| 555 | Sets whether the item at index [param idx] has a checkbox. If [code]false[/code], sets the type of the item to plain text. |
| 556 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 557 | </description> |
| 558 | </method> |
| 559 | <method name="set_item_checked"> |
| 560 | <return type="void" /> |
| 561 | <param index="0" name="rid" type="RID" /> |
| 562 | <param index="1" name="idx" type="int" /> |
| 563 | <param index="2" name="checked" type="bool" /> |
| 564 | <description> |
| 565 | Sets the checkstate status of the item at index [param idx]. |
| 566 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 567 | </description> |
| 568 | </method> |
| 569 | <method name="set_item_disabled"> |
| 570 | <return type="void" /> |
| 571 | <param index="0" name="rid" type="RID" /> |
| 572 | <param index="1" name="idx" type="int" /> |
| 573 | <param index="2" name="disabled" type="bool" /> |
| 574 | <description> |
| 575 | Enables/disables the item at index [param idx]. When it is disabled, it can't be selected and its action can't be invoked. |
| 576 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 577 | </description> |
| 578 | </method> |
| 579 | <method name="set_item_hidden"> |
| 580 | <return type="void" /> |
| 581 | <param index="0" name="rid" type="RID" /> |
| 582 | <param index="1" name="idx" type="int" /> |
| 583 | <param index="2" name="hidden" type="bool" /> |
| 584 | <description> |
| 585 | Hides/shows the item at index [param idx]. When it is hidden, an item does not appear in a menu and its action cannot be invoked. |
| 586 | [b]Note:[/b] This method is implemented only on macOS. |
| 587 | </description> |
| 588 | </method> |
| 589 | <method name="set_item_hover_callbacks"> |
| 590 | <return type="void" /> |
| 591 | <param index="0" name="rid" type="RID" /> |
| 592 | <param index="1" name="idx" type="int" /> |
| 593 | <param index="2" name="callback" type="Callable" /> |
| 594 | <description> |
| 595 | Sets the callback of the item at index [param idx]. The callback is emitted when an item is hovered. |
| 596 | [b]Note:[/b] The [param callback] Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the [code]tag[/code] parameter when the menu item was created. |
| 597 | [b]Note:[/b] This method is implemented only on macOS. |
| 598 | </description> |
| 599 | </method> |
| 600 | <method name="set_item_icon"> |
| 601 | <return type="void" /> |
| 602 | <param index="0" name="rid" type="RID" /> |
| 603 | <param index="1" name="idx" type="int" /> |
| 604 | <param index="2" name="icon" type="Texture2D" /> |
| 605 | <description> |
| 606 | Replaces the [Texture2D] icon of the specified [param idx]. |
| 607 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 608 | [b]Note:[/b] This method is not supported by macOS Dock menu items. |
| 609 | </description> |
| 610 | </method> |
| 611 | <method name="set_item_indentation_level"> |
| 612 | <return type="void" /> |
| 613 | <param index="0" name="rid" type="RID" /> |
| 614 | <param index="1" name="idx" type="int" /> |
| 615 | <param index="2" name="level" type="int" /> |
| 616 | <description> |
| 617 | Sets the horizontal offset of the item at the given [param idx]. |
| 618 | [b]Note:[/b] This method is implemented only on macOS. |
| 619 | </description> |
| 620 | </method> |
| 621 | <method name="set_item_key_callback"> |
| 622 | <return type="void" /> |
| 623 | <param index="0" name="rid" type="RID" /> |
| 624 | <param index="1" name="idx" type="int" /> |
| 625 | <param index="2" name="key_callback" type="Callable" /> |
| 626 | <description> |
| 627 | Sets the callback of the item at index [param idx]. Callback is emitted when its accelerator is activated. |
| 628 | [b]Note:[/b] The [param key_callback] Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the [code]tag[/code] parameter when the menu item was created. |
| 629 | [b]Note:[/b] This method is implemented only on macOS. |
| 630 | </description> |
| 631 | </method> |
| 632 | <method name="set_item_max_states"> |
| 633 | <return type="void" /> |
| 634 | <param index="0" name="rid" type="RID" /> |
| 635 | <param index="1" name="idx" type="int" /> |
| 636 | <param index="2" name="max_states" type="int" /> |
| 637 | <description> |
| 638 | Sets number of state of a multistate item. See [method add_multistate_item] for details. |
| 639 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 640 | </description> |
| 641 | </method> |
| 642 | <method name="set_item_radio_checkable"> |
| 643 | <return type="void" /> |
| 644 | <param index="0" name="rid" type="RID" /> |
| 645 | <param index="1" name="idx" type="int" /> |
| 646 | <param index="2" name="checkable" type="bool" /> |
| 647 | <description> |
| 648 | Sets the type of the item at the specified index [param idx] to radio button. If [code]false[/code], sets the type of the item to plain text. |
| 649 | [b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups. |
| 650 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 651 | </description> |
| 652 | </method> |
| 653 | <method name="set_item_state"> |
| 654 | <return type="void" /> |
| 655 | <param index="0" name="rid" type="RID" /> |
| 656 | <param index="1" name="idx" type="int" /> |
| 657 | <param index="2" name="state" type="int" /> |
| 658 | <description> |
| 659 | Sets the state of a multistate item. See [method add_multistate_item] for details. |
| 660 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 661 | </description> |
| 662 | </method> |
| 663 | <method name="set_item_submenu"> |
| 664 | <return type="void" /> |
| 665 | <param index="0" name="rid" type="RID" /> |
| 666 | <param index="1" name="idx" type="int" /> |
| 667 | <param index="2" name="submenu_rid" type="RID" /> |
| 668 | <description> |
| 669 | Sets the submenu RID of the item at index [param idx]. The submenu is a global menu that would be shown when the item is clicked. |
| 670 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 671 | </description> |
| 672 | </method> |
| 673 | <method name="set_item_tag"> |
| 674 | <return type="void" /> |
| 675 | <param index="0" name="rid" type="RID" /> |
| 676 | <param index="1" name="idx" type="int" /> |
| 677 | <param index="2" name="tag" type="Variant" /> |
| 678 | <description> |
| 679 | Sets the metadata of an item, which may be of any type. You can later get it with [method get_item_tag], which provides a simple way of assigning context data to items. |
| 680 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 681 | </description> |
| 682 | </method> |
| 683 | <method name="set_item_text"> |
| 684 | <return type="void" /> |
| 685 | <param index="0" name="rid" type="RID" /> |
| 686 | <param index="1" name="idx" type="int" /> |
| 687 | <param index="2" name="text" type="String" /> |
| 688 | <description> |
| 689 | Sets the text of the item at index [param idx]. |
| 690 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 691 | </description> |
| 692 | </method> |
| 693 | <method name="set_item_tooltip"> |
| 694 | <return type="void" /> |
| 695 | <param index="0" name="rid" type="RID" /> |
| 696 | <param index="1" name="idx" type="int" /> |
| 697 | <param index="2" name="tooltip" type="String" /> |
| 698 | <description> |
| 699 | Sets the [String] tooltip of the item at the specified index [param idx]. |
| 700 | [b]Note:[/b] This method is implemented only on macOS. |
| 701 | </description> |
| 702 | </method> |
| 703 | <method name="set_minimum_width"> |
| 704 | <return type="void" /> |
| 705 | <param index="0" name="rid" type="RID" /> |
| 706 | <param index="1" name="width" type="float" /> |
| 707 | <description> |
| 708 | Sets the minimum width of the global menu. |
| 709 | [b]Note:[/b] This method is implemented only on macOS. |
| 710 | </description> |
| 711 | </method> |
| 712 | <method name="set_popup_close_callback"> |
| 713 | <return type="void" /> |
| 714 | <param index="0" name="rid" type="RID" /> |
| 715 | <param index="1" name="callback" type="Callable" /> |
| 716 | <description> |
| 717 | Registers callable to emit when the menu is about to show. |
| 718 | [b]Note:[/b] The OS can simulate menu opening to track menu item changes and global shortcuts, in which case the corresponding close callback is not triggered. Use [method is_opened] to check if the menu is currently opened. |
| 719 | [b]Note:[/b] This method is implemented on macOS and Windows. |
| 720 | </description> |
| 721 | </method> |
| 722 | <method name="set_popup_open_callback"> |
| 723 | <return type="void" /> |
| 724 | <param index="0" name="rid" type="RID" /> |
| 725 | <param index="1" name="callback" type="Callable" /> |
| 726 | <description> |
| 727 | Registers callable to emit after the menu is closed. |
| 728 | [b]Note:[/b] This method is implemented only on macOS. |
| 729 | </description> |
| 730 | </method> |
| 731 | <method name="set_system_menu_text"> |
| 732 | <return type="void" /> |
| 733 | <param index="0" name="menu_id" type="int" enum="NativeMenu.SystemMenus" /> |
| 734 | <param index="1" name="name" type="String" /> |
| 735 | <description> |
| 736 | Sets the text of the system menu item. |
| 737 | [b]Note:[/b] This method is implemented on macOS. |
| 738 | </description> |
| 739 | </method> |
| 740 | </methods> |
| 741 | <constants> |
| 742 | <constant name="FEATURE_GLOBAL_MENU" value="0" enum="Feature"> |
| 743 | [NativeMenu] supports native global main menu. |
| 744 | </constant> |
| 745 | <constant name="FEATURE_POPUP_MENU" value="1" enum="Feature"> |
| 746 | [NativeMenu] supports native popup menus. |
| 747 | </constant> |
| 748 | <constant name="FEATURE_OPEN_CLOSE_CALLBACK" value="2" enum="Feature"> |
| 749 | [NativeMenu] supports menu open and close callbacks. |
| 750 | </constant> |
| 751 | <constant name="FEATURE_HOVER_CALLBACK" value="3" enum="Feature"> |
| 752 | [NativeMenu] supports menu item hover callback. |
| 753 | </constant> |
| 754 | <constant name="FEATURE_KEY_CALLBACK" value="4" enum="Feature"> |
| 755 | [NativeMenu] supports menu item accelerator/key callback. |
| 756 | </constant> |
| 757 | <constant name="INVALID_MENU_ID" value="0" enum="SystemMenus"> |
| 758 | Invalid special system menu ID. |
| 759 | </constant> |
| 760 | <constant name="MAIN_MENU_ID" value="1" enum="SystemMenus"> |
| 761 | Global main menu ID. |
| 762 | </constant> |
| 763 | <constant name="APPLICATION_MENU_ID" value="2" enum="SystemMenus"> |
| 764 | Application (first menu after "Apple" menu on macOS) menu ID. |
| 765 | </constant> |
| 766 | <constant name="WINDOW_MENU_ID" value="3" enum="SystemMenus"> |
| 767 | "Window" menu ID (on macOS this menu includes standard window control items and a list of open windows). |
| 768 | </constant> |
| 769 | <constant name="HELP_MENU_ID" value="4" enum="SystemMenus"> |
| 770 | "Help" menu ID (on macOS this menu includes help search bar). |
| 771 | </constant> |
| 772 | <constant name="DOCK_MENU_ID" value="5" enum="SystemMenus"> |
| 773 | Dock icon right-click menu ID (on macOS this menu include standard application control items and a list of open windows). |
| 774 | </constant> |
| 775 | </constants> |
| 776 | </class> |