1 /** 2 PopupMenu displays a list of options. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.popupmenu; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.popup; 25 import godot.control; 26 import godot.canvasitem; 27 import godot.node; 28 import godot.inputevent; 29 import godot.shortcut; 30 import godot.texture; 31 /** 32 PopupMenu displays a list of options. 33 34 $(D PopupMenu) is a $(D Control) that displays a list of options. They are popular in toolbars or context menus. 35 */ 36 @GodotBaseClass struct PopupMenu 37 { 38 package(godot) enum string _GODOT_internal_name = "PopupMenu"; 39 public: 40 @nogc nothrow: 41 union { /** */ godot_object _godot_object; /** */ Popup _GODOT_base; } 42 alias _GODOT_base this; 43 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 44 package(godot) __gshared bool _classBindingInitialized = false; 45 package(godot) static struct GDNativeClassBinding 46 { 47 __gshared: 48 @GodotName("_get_items") GodotMethod!(Array) _getItems; 49 @GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput; 50 @GodotName("_set_items") GodotMethod!(void, Array) _setItems; 51 @GodotName("_submenu_timeout") GodotMethod!(void) _submenuTimeout; 52 @GodotName("add_check_item") GodotMethod!(void, String, long, long) addCheckItem; 53 @GodotName("add_check_shortcut") GodotMethod!(void, ShortCut, long, bool) addCheckShortcut; 54 @GodotName("add_icon_check_item") GodotMethod!(void, Texture, String, long, long) addIconCheckItem; 55 @GodotName("add_icon_check_shortcut") GodotMethod!(void, Texture, ShortCut, long, bool) addIconCheckShortcut; 56 @GodotName("add_icon_item") GodotMethod!(void, Texture, String, long, long) addIconItem; 57 @GodotName("add_icon_radio_check_item") GodotMethod!(void, Texture, String, long, long) addIconRadioCheckItem; 58 @GodotName("add_icon_radio_check_shortcut") GodotMethod!(void, Texture, ShortCut, long, bool) addIconRadioCheckShortcut; 59 @GodotName("add_icon_shortcut") GodotMethod!(void, Texture, ShortCut, long, bool) addIconShortcut; 60 @GodotName("add_item") GodotMethod!(void, String, long, long) addItem; 61 @GodotName("add_multistate_item") GodotMethod!(void, String, long, long, long, long) addMultistateItem; 62 @GodotName("add_radio_check_item") GodotMethod!(void, String, long, long) addRadioCheckItem; 63 @GodotName("add_radio_check_shortcut") GodotMethod!(void, ShortCut, long, bool) addRadioCheckShortcut; 64 @GodotName("add_separator") GodotMethod!(void, String, long) addSeparator; 65 @GodotName("add_shortcut") GodotMethod!(void, ShortCut, long, bool) addShortcut; 66 @GodotName("add_submenu_item") GodotMethod!(void, String, String, long) addSubmenuItem; 67 @GodotName("clear") GodotMethod!(void) clear; 68 @GodotName("get_allow_search") GodotMethod!(bool) getAllowSearch; 69 @GodotName("get_current_index") GodotMethod!(long) getCurrentIndex; 70 @GodotName("get_item_accelerator") GodotMethod!(long, long) getItemAccelerator; 71 @GodotName("get_item_count") GodotMethod!(long) getItemCount; 72 @GodotName("get_item_icon") GodotMethod!(Texture, long) getItemIcon; 73 @GodotName("get_item_id") GodotMethod!(long, long) getItemId; 74 @GodotName("get_item_index") GodotMethod!(long, long) getItemIndex; 75 @GodotName("get_item_metadata") GodotMethod!(Variant, long) getItemMetadata; 76 @GodotName("get_item_shortcut") GodotMethod!(ShortCut, long) getItemShortcut; 77 @GodotName("get_item_submenu") GodotMethod!(String, long) getItemSubmenu; 78 @GodotName("get_item_text") GodotMethod!(String, long) getItemText; 79 @GodotName("get_item_tooltip") GodotMethod!(String, long) getItemTooltip; 80 @GodotName("get_submenu_popup_delay") GodotMethod!(double) getSubmenuPopupDelay; 81 @GodotName("is_hide_on_checkable_item_selection") GodotMethod!(bool) isHideOnCheckableItemSelection; 82 @GodotName("is_hide_on_item_selection") GodotMethod!(bool) isHideOnItemSelection; 83 @GodotName("is_hide_on_state_item_selection") GodotMethod!(bool) isHideOnStateItemSelection; 84 @GodotName("is_hide_on_window_lose_focus") GodotMethod!(bool) isHideOnWindowLoseFocus; 85 @GodotName("is_item_checkable") GodotMethod!(bool, long) isItemCheckable; 86 @GodotName("is_item_checked") GodotMethod!(bool, long) isItemChecked; 87 @GodotName("is_item_disabled") GodotMethod!(bool, long) isItemDisabled; 88 @GodotName("is_item_radio_checkable") GodotMethod!(bool, long) isItemRadioCheckable; 89 @GodotName("is_item_separator") GodotMethod!(bool, long) isItemSeparator; 90 @GodotName("is_item_shortcut_disabled") GodotMethod!(bool, long) isItemShortcutDisabled; 91 @GodotName("remove_item") GodotMethod!(void, long) removeItem; 92 @GodotName("set_allow_search") GodotMethod!(void, bool) setAllowSearch; 93 @GodotName("set_hide_on_checkable_item_selection") GodotMethod!(void, bool) setHideOnCheckableItemSelection; 94 @GodotName("set_hide_on_item_selection") GodotMethod!(void, bool) setHideOnItemSelection; 95 @GodotName("set_hide_on_state_item_selection") GodotMethod!(void, bool) setHideOnStateItemSelection; 96 @GodotName("set_hide_on_window_lose_focus") GodotMethod!(void, bool) setHideOnWindowLoseFocus; 97 @GodotName("set_item_accelerator") GodotMethod!(void, long, long) setItemAccelerator; 98 @GodotName("set_item_as_checkable") GodotMethod!(void, long, bool) setItemAsCheckable; 99 @GodotName("set_item_as_radio_checkable") GodotMethod!(void, long, bool) setItemAsRadioCheckable; 100 @GodotName("set_item_as_separator") GodotMethod!(void, long, bool) setItemAsSeparator; 101 @GodotName("set_item_checked") GodotMethod!(void, long, bool) setItemChecked; 102 @GodotName("set_item_disabled") GodotMethod!(void, long, bool) setItemDisabled; 103 @GodotName("set_item_icon") GodotMethod!(void, long, Texture) setItemIcon; 104 @GodotName("set_item_id") GodotMethod!(void, long, long) setItemId; 105 @GodotName("set_item_metadata") GodotMethod!(void, long, Variant) setItemMetadata; 106 @GodotName("set_item_multistate") GodotMethod!(void, long, long) setItemMultistate; 107 @GodotName("set_item_shortcut") GodotMethod!(void, long, ShortCut, bool) setItemShortcut; 108 @GodotName("set_item_shortcut_disabled") GodotMethod!(void, long, bool) setItemShortcutDisabled; 109 @GodotName("set_item_submenu") GodotMethod!(void, long, String) setItemSubmenu; 110 @GodotName("set_item_text") GodotMethod!(void, long, String) setItemText; 111 @GodotName("set_item_tooltip") GodotMethod!(void, long, String) setItemTooltip; 112 @GodotName("set_submenu_popup_delay") GodotMethod!(void, double) setSubmenuPopupDelay; 113 @GodotName("toggle_item_checked") GodotMethod!(void, long) toggleItemChecked; 114 @GodotName("toggle_item_multistate") GodotMethod!(void, long) toggleItemMultistate; 115 } 116 /// 117 pragma(inline, true) bool opEquals(in PopupMenu other) const 118 { return _godot_object.ptr is other._godot_object.ptr; } 119 /// 120 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 121 { _godot_object.ptr = n; return null; } 122 /// 123 pragma(inline, true) bool opEquals(typeof(null) n) const 124 { return _godot_object.ptr is n; } 125 /// 126 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 127 mixin baseCasts; 128 /// Construct a new instance of PopupMenu. 129 /// Note: use `memnew!PopupMenu` instead. 130 static PopupMenu _new() 131 { 132 static godot_class_constructor constructor; 133 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PopupMenu"); 134 if(constructor is null) return typeof(this).init; 135 return cast(PopupMenu)(constructor()); 136 } 137 @disable new(size_t s); 138 /** 139 140 */ 141 Array _getItems() const 142 { 143 Array _GODOT_args = Array.make(); 144 String _GODOT_method_name = String("_get_items"); 145 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 146 } 147 /** 148 149 */ 150 void _guiInput(InputEvent arg0) 151 { 152 Array _GODOT_args = Array.make(); 153 _GODOT_args.append(arg0); 154 String _GODOT_method_name = String("_gui_input"); 155 this.callv(_GODOT_method_name, _GODOT_args); 156 } 157 /** 158 159 */ 160 void _setItems(in Array arg0) 161 { 162 Array _GODOT_args = Array.make(); 163 _GODOT_args.append(arg0); 164 String _GODOT_method_name = String("_set_items"); 165 this.callv(_GODOT_method_name, _GODOT_args); 166 } 167 /** 168 169 */ 170 void _submenuTimeout() 171 { 172 Array _GODOT_args = Array.make(); 173 String _GODOT_method_name = String("_submenu_timeout"); 174 this.callv(_GODOT_method_name, _GODOT_args); 175 } 176 /** 177 Adds a new checkable item with text `label`. 178 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 179 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 180 */ 181 void addCheckItem(in String label, in long id = -1, in long accel = 0) 182 { 183 checkClassBinding!(typeof(this))(); 184 ptrcall!(void)(GDNativeClassBinding.addCheckItem, _godot_object, label, id, accel); 185 } 186 /** 187 Adds a new checkable item and assigns the specified $(D ShortCut) to it. Sets the label of the checkbox to the $(D ShortCut)'s name. 188 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 189 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 190 */ 191 void addCheckShortcut(ShortCut shortcut, in long id = -1, in bool global = false) 192 { 193 checkClassBinding!(typeof(this))(); 194 ptrcall!(void)(GDNativeClassBinding.addCheckShortcut, _godot_object, shortcut, id, global); 195 } 196 /** 197 Adds a new checkable item with text `label` and icon `texture`. 198 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 199 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 200 */ 201 void addIconCheckItem(Texture texture, in String label, in long id = -1, in long accel = 0) 202 { 203 checkClassBinding!(typeof(this))(); 204 ptrcall!(void)(GDNativeClassBinding.addIconCheckItem, _godot_object, texture, label, id, accel); 205 } 206 /** 207 Adds a new checkable item and assigns the specified $(D ShortCut) and icon `texture` to it. Sets the label of the checkbox to the $(D ShortCut)'s name. 208 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 209 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 210 */ 211 void addIconCheckShortcut(Texture texture, ShortCut shortcut, in long id = -1, in bool global = false) 212 { 213 checkClassBinding!(typeof(this))(); 214 ptrcall!(void)(GDNativeClassBinding.addIconCheckShortcut, _godot_object, texture, shortcut, id, global); 215 } 216 /** 217 Adds a new item with text `label` and icon `texture`. 218 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 219 */ 220 void addIconItem(Texture texture, in String label, in long id = -1, in long accel = 0) 221 { 222 checkClassBinding!(typeof(this))(); 223 ptrcall!(void)(GDNativeClassBinding.addIconItem, _godot_object, texture, label, id, accel); 224 } 225 /** 226 Same as $(D addIconCheckItem), but uses a radio check button. 227 */ 228 void addIconRadioCheckItem(Texture texture, in String label, in long id = -1, in long accel = 0) 229 { 230 checkClassBinding!(typeof(this))(); 231 ptrcall!(void)(GDNativeClassBinding.addIconRadioCheckItem, _godot_object, texture, label, id, accel); 232 } 233 /** 234 Same as $(D addIconCheckShortcut), but uses a radio check button. 235 */ 236 void addIconRadioCheckShortcut(Texture texture, ShortCut shortcut, in long id = -1, in bool global = false) 237 { 238 checkClassBinding!(typeof(this))(); 239 ptrcall!(void)(GDNativeClassBinding.addIconRadioCheckShortcut, _godot_object, texture, shortcut, id, global); 240 } 241 /** 242 Adds a new item and assigns the specified $(D ShortCut) and icon `texture` to it. Sets the label of the checkbox to the $(D ShortCut)'s name. 243 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 244 */ 245 void addIconShortcut(Texture texture, ShortCut shortcut, in long id = -1, in bool global = false) 246 { 247 checkClassBinding!(typeof(this))(); 248 ptrcall!(void)(GDNativeClassBinding.addIconShortcut, _godot_object, texture, shortcut, id, global); 249 } 250 /** 251 Adds a new item with text `label`. 252 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 253 */ 254 void addItem(in String label, in long id = -1, in long accel = 0) 255 { 256 checkClassBinding!(typeof(this))(); 257 ptrcall!(void)(GDNativeClassBinding.addItem, _godot_object, label, id, accel); 258 } 259 /** 260 Adds a new multistate item with text `label`. 261 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`. 262 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 263 */ 264 void addMultistateItem(in String label, in long max_states, in long default_state = 0, in long id = -1, in long accel = 0) 265 { 266 checkClassBinding!(typeof(this))(); 267 ptrcall!(void)(GDNativeClassBinding.addMultistateItem, _godot_object, label, max_states, default_state, id, accel); 268 } 269 /** 270 Adds a new radio check button with text `label`. 271 An `id` can optionally be provided, as well as an accelerator (`accel`). If no `id` is provided, one will be created from the index. If no `accel` is provided then the default `0` will be assigned to it. See $(D getItemAccelerator) for more info on accelerators. 272 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 273 */ 274 void addRadioCheckItem(in String label, in long id = -1, in long accel = 0) 275 { 276 checkClassBinding!(typeof(this))(); 277 ptrcall!(void)(GDNativeClassBinding.addRadioCheckItem, _godot_object, label, id, accel); 278 } 279 /** 280 Adds a new radio check button and assigns a $(D ShortCut) to it. Sets the label of the checkbox to the $(D ShortCut)'s name. 281 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 282 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See $(D setItemChecked) for more info on how to control it. 283 */ 284 void addRadioCheckShortcut(ShortCut shortcut, in long id = -1, in bool global = false) 285 { 286 checkClassBinding!(typeof(this))(); 287 ptrcall!(void)(GDNativeClassBinding.addRadioCheckShortcut, _godot_object, shortcut, id, global); 288 } 289 /** 290 Adds a separator between items. Separators also occupy an index, which you can set by using the `id` parameter. 291 A `label` can optionally be provided, which will appear at the center of the separator. 292 */ 293 void addSeparator(in String label = gs!"", in long id = -1) 294 { 295 checkClassBinding!(typeof(this))(); 296 ptrcall!(void)(GDNativeClassBinding.addSeparator, _godot_object, label, id); 297 } 298 /** 299 Adds a $(D ShortCut). 300 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 301 */ 302 void addShortcut(ShortCut shortcut, in long id = -1, in bool global = false) 303 { 304 checkClassBinding!(typeof(this))(); 305 ptrcall!(void)(GDNativeClassBinding.addShortcut, _godot_object, shortcut, id, global); 306 } 307 /** 308 Adds an item that will act as a submenu of the parent $(D PopupMenu) node when clicked. The `submenu` argument is the name of the child $(D PopupMenu) node that will be shown when the item is clicked. 309 An `id` can optionally be provided. If no `id` is provided, one will be created from the index. 310 */ 311 void addSubmenuItem(in String label, in String submenu, in long id = -1) 312 { 313 checkClassBinding!(typeof(this))(); 314 ptrcall!(void)(GDNativeClassBinding.addSubmenuItem, _godot_object, label, submenu, id); 315 } 316 /** 317 Removes all items from the $(D PopupMenu). 318 */ 319 void clear() 320 { 321 checkClassBinding!(typeof(this))(); 322 ptrcall!(void)(GDNativeClassBinding.clear, _godot_object); 323 } 324 /** 325 326 */ 327 bool getAllowSearch() const 328 { 329 checkClassBinding!(typeof(this))(); 330 return ptrcall!(bool)(GDNativeClassBinding.getAllowSearch, _godot_object); 331 } 332 /** 333 Returns the index of the currently focused item. Returns `-1` if no item is focused. 334 */ 335 long getCurrentIndex() const 336 { 337 checkClassBinding!(typeof(this))(); 338 return ptrcall!(long)(GDNativeClassBinding.getCurrentIndex, _godot_object); 339 } 340 /** 341 Returns the accelerator of the item at index `idx`. Accelerators are special combinations of keys that activate the item, no matter which control is focused. 342 */ 343 long getItemAccelerator(in long idx) const 344 { 345 checkClassBinding!(typeof(this))(); 346 return ptrcall!(long)(GDNativeClassBinding.getItemAccelerator, _godot_object, idx); 347 } 348 /** 349 Returns the number of items in the $(D PopupMenu). 350 */ 351 long getItemCount() const 352 { 353 checkClassBinding!(typeof(this))(); 354 return ptrcall!(long)(GDNativeClassBinding.getItemCount, _godot_object); 355 } 356 /** 357 Returns the icon of the item at index `idx`. 358 */ 359 Ref!Texture getItemIcon(in long idx) const 360 { 361 checkClassBinding!(typeof(this))(); 362 return ptrcall!(Texture)(GDNativeClassBinding.getItemIcon, _godot_object, idx); 363 } 364 /** 365 Returns the id of the item at index `idx`. `id` can be manually assigned, while index can not. 366 */ 367 long getItemId(in long idx) const 368 { 369 checkClassBinding!(typeof(this))(); 370 return ptrcall!(long)(GDNativeClassBinding.getItemId, _godot_object, idx); 371 } 372 /** 373 Returns the index of the item containing the specified `id`. Index is automatically assigned to each item by the engine. Index can not be set manually. 374 */ 375 long getItemIndex(in long id) const 376 { 377 checkClassBinding!(typeof(this))(); 378 return ptrcall!(long)(GDNativeClassBinding.getItemIndex, _godot_object, id); 379 } 380 /** 381 Returns the metadata of the specified item, which might be of any type. You can set it with $(D setItemMetadata), which provides a simple way of assigning context data to items. 382 */ 383 Variant getItemMetadata(in long idx) const 384 { 385 checkClassBinding!(typeof(this))(); 386 return ptrcall!(Variant)(GDNativeClassBinding.getItemMetadata, _godot_object, idx); 387 } 388 /** 389 Returns the $(D ShortCut) associated with the specified `idx` item. 390 */ 391 Ref!ShortCut getItemShortcut(in long idx) const 392 { 393 checkClassBinding!(typeof(this))(); 394 return ptrcall!(ShortCut)(GDNativeClassBinding.getItemShortcut, _godot_object, idx); 395 } 396 /** 397 Returns the submenu name of the item at index `idx`. See $(D addSubmenuItem) for more info on how to add a submenu. 398 */ 399 String getItemSubmenu(in long idx) const 400 { 401 checkClassBinding!(typeof(this))(); 402 return ptrcall!(String)(GDNativeClassBinding.getItemSubmenu, _godot_object, idx); 403 } 404 /** 405 Returns the text of the item at index `idx`. 406 */ 407 String getItemText(in long idx) const 408 { 409 checkClassBinding!(typeof(this))(); 410 return ptrcall!(String)(GDNativeClassBinding.getItemText, _godot_object, idx); 411 } 412 /** 413 Returns the tooltip associated with the specified index index `idx`. 414 */ 415 String getItemTooltip(in long idx) const 416 { 417 checkClassBinding!(typeof(this))(); 418 return ptrcall!(String)(GDNativeClassBinding.getItemTooltip, _godot_object, idx); 419 } 420 /** 421 422 */ 423 double getSubmenuPopupDelay() const 424 { 425 checkClassBinding!(typeof(this))(); 426 return ptrcall!(double)(GDNativeClassBinding.getSubmenuPopupDelay, _godot_object); 427 } 428 /** 429 430 */ 431 bool isHideOnCheckableItemSelection() const 432 { 433 checkClassBinding!(typeof(this))(); 434 return ptrcall!(bool)(GDNativeClassBinding.isHideOnCheckableItemSelection, _godot_object); 435 } 436 /** 437 438 */ 439 bool isHideOnItemSelection() const 440 { 441 checkClassBinding!(typeof(this))(); 442 return ptrcall!(bool)(GDNativeClassBinding.isHideOnItemSelection, _godot_object); 443 } 444 /** 445 446 */ 447 bool isHideOnStateItemSelection() const 448 { 449 checkClassBinding!(typeof(this))(); 450 return ptrcall!(bool)(GDNativeClassBinding.isHideOnStateItemSelection, _godot_object); 451 } 452 /** 453 Returns `true` if the popup will be hidden when the window loses focus or not. 454 */ 455 bool isHideOnWindowLoseFocus() const 456 { 457 checkClassBinding!(typeof(this))(); 458 return ptrcall!(bool)(GDNativeClassBinding.isHideOnWindowLoseFocus, _godot_object); 459 } 460 /** 461 Returns `true` if the item at index `idx` is checkable in some way, i.e. if it has a checkbox or radio button. 462 $(B Note:) Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually. 463 */ 464 bool isItemCheckable(in long idx) const 465 { 466 checkClassBinding!(typeof(this))(); 467 return ptrcall!(bool)(GDNativeClassBinding.isItemCheckable, _godot_object, idx); 468 } 469 /** 470 Returns `true` if the item at index `idx` is checked. 471 */ 472 bool isItemChecked(in long idx) const 473 { 474 checkClassBinding!(typeof(this))(); 475 return ptrcall!(bool)(GDNativeClassBinding.isItemChecked, _godot_object, idx); 476 } 477 /** 478 Returns `true` if the item at index `idx` is disabled. When it is disabled it can't be selected, or its action invoked. 479 See $(D setItemDisabled) for more info on how to disable an item. 480 */ 481 bool isItemDisabled(in long idx) const 482 { 483 checkClassBinding!(typeof(this))(); 484 return ptrcall!(bool)(GDNativeClassBinding.isItemDisabled, _godot_object, idx); 485 } 486 /** 487 Returns `true` if the item at index `idx` has radio button-style checkability. 488 $(B Note:) This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups. 489 */ 490 bool isItemRadioCheckable(in long idx) const 491 { 492 checkClassBinding!(typeof(this))(); 493 return ptrcall!(bool)(GDNativeClassBinding.isItemRadioCheckable, _godot_object, idx); 494 } 495 /** 496 Returns `true` if the item is a separator. If it is, it will be displayed as a line. See $(D addSeparator) for more info on how to add a separator. 497 */ 498 bool isItemSeparator(in long idx) const 499 { 500 checkClassBinding!(typeof(this))(); 501 return ptrcall!(bool)(GDNativeClassBinding.isItemSeparator, _godot_object, idx); 502 } 503 /** 504 Returns `true` if the specified item's shortcut is disabled. 505 */ 506 bool isItemShortcutDisabled(in long idx) const 507 { 508 checkClassBinding!(typeof(this))(); 509 return ptrcall!(bool)(GDNativeClassBinding.isItemShortcutDisabled, _godot_object, idx); 510 } 511 /** 512 Removes the item at index `idx` from the menu. 513 $(B Note:) The indices of items after the removed item will be shifted by one. 514 */ 515 void removeItem(in long idx) 516 { 517 checkClassBinding!(typeof(this))(); 518 ptrcall!(void)(GDNativeClassBinding.removeItem, _godot_object, idx); 519 } 520 /** 521 522 */ 523 void setAllowSearch(in bool allow) 524 { 525 checkClassBinding!(typeof(this))(); 526 ptrcall!(void)(GDNativeClassBinding.setAllowSearch, _godot_object, allow); 527 } 528 /** 529 530 */ 531 void setHideOnCheckableItemSelection(in bool enable) 532 { 533 checkClassBinding!(typeof(this))(); 534 ptrcall!(void)(GDNativeClassBinding.setHideOnCheckableItemSelection, _godot_object, enable); 535 } 536 /** 537 538 */ 539 void setHideOnItemSelection(in bool enable) 540 { 541 checkClassBinding!(typeof(this))(); 542 ptrcall!(void)(GDNativeClassBinding.setHideOnItemSelection, _godot_object, enable); 543 } 544 /** 545 546 */ 547 void setHideOnStateItemSelection(in bool enable) 548 { 549 checkClassBinding!(typeof(this))(); 550 ptrcall!(void)(GDNativeClassBinding.setHideOnStateItemSelection, _godot_object, enable); 551 } 552 /** 553 Hides the $(D PopupMenu) when the window loses focus. 554 */ 555 void setHideOnWindowLoseFocus(in bool enable) 556 { 557 checkClassBinding!(typeof(this))(); 558 ptrcall!(void)(GDNativeClassBinding.setHideOnWindowLoseFocus, _godot_object, enable); 559 } 560 /** 561 Sets the accelerator of the item at index `idx`. Accelerators are special combinations of keys that activate the item, no matter which control is focused. 562 */ 563 void setItemAccelerator(in long idx, in long accel) 564 { 565 checkClassBinding!(typeof(this))(); 566 ptrcall!(void)(GDNativeClassBinding.setItemAccelerator, _godot_object, idx, accel); 567 } 568 /** 569 Sets whether the item at index `idx` has a checkbox. If `false`, sets the type of the item to plain text. 570 $(B Note:) Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. 571 */ 572 void setItemAsCheckable(in long idx, in bool enable) 573 { 574 checkClassBinding!(typeof(this))(); 575 ptrcall!(void)(GDNativeClassBinding.setItemAsCheckable, _godot_object, idx, enable); 576 } 577 /** 578 Sets the type of the item at the specified index `idx` to radio button. If `false`, sets the type of the item to plain text. 579 */ 580 void setItemAsRadioCheckable(in long idx, in bool enable) 581 { 582 checkClassBinding!(typeof(this))(); 583 ptrcall!(void)(GDNativeClassBinding.setItemAsRadioCheckable, _godot_object, idx, enable); 584 } 585 /** 586 Mark the item at index `idx` as a separator, which means that it would be displayed as a line. If `false`, sets the type of the item to plain text. 587 */ 588 void setItemAsSeparator(in long idx, in bool enable) 589 { 590 checkClassBinding!(typeof(this))(); 591 ptrcall!(void)(GDNativeClassBinding.setItemAsSeparator, _godot_object, idx, enable); 592 } 593 /** 594 Sets the checkstate status of the item at index `idx`. 595 */ 596 void setItemChecked(in long idx, in bool checked) 597 { 598 checkClassBinding!(typeof(this))(); 599 ptrcall!(void)(GDNativeClassBinding.setItemChecked, _godot_object, idx, checked); 600 } 601 /** 602 Enables/disables the item at index `idx`. When it is disabled, it can't be selected and its action can't be invoked. 603 */ 604 void setItemDisabled(in long idx, in bool disabled) 605 { 606 checkClassBinding!(typeof(this))(); 607 ptrcall!(void)(GDNativeClassBinding.setItemDisabled, _godot_object, idx, disabled); 608 } 609 /** 610 Replaces the $(D Texture) icon of the specified `idx`. 611 */ 612 void setItemIcon(in long idx, Texture icon) 613 { 614 checkClassBinding!(typeof(this))(); 615 ptrcall!(void)(GDNativeClassBinding.setItemIcon, _godot_object, idx, icon); 616 } 617 /** 618 Sets the `id` of the item at index `idx`. 619 */ 620 void setItemId(in long idx, in long id) 621 { 622 checkClassBinding!(typeof(this))(); 623 ptrcall!(void)(GDNativeClassBinding.setItemId, _godot_object, idx, id); 624 } 625 /** 626 Sets the metadata of an item, which may be of any type. You can later get it with $(D getItemMetadata), which provides a simple way of assigning context data to items. 627 */ 628 void setItemMetadata(VariantArg1)(in long idx, in VariantArg1 metadata) 629 { 630 checkClassBinding!(typeof(this))(); 631 ptrcall!(void)(GDNativeClassBinding.setItemMetadata, _godot_object, idx, metadata); 632 } 633 /** 634 Sets the state of a multistate item. See $(D addMultistateItem) for details. 635 */ 636 void setItemMultistate(in long idx, in long state) 637 { 638 checkClassBinding!(typeof(this))(); 639 ptrcall!(void)(GDNativeClassBinding.setItemMultistate, _godot_object, idx, state); 640 } 641 /** 642 Sets a $(D ShortCut) for the specified item `idx`. 643 */ 644 void setItemShortcut(in long idx, ShortCut shortcut, in bool global = false) 645 { 646 checkClassBinding!(typeof(this))(); 647 ptrcall!(void)(GDNativeClassBinding.setItemShortcut, _godot_object, idx, shortcut, global); 648 } 649 /** 650 Disables the $(D ShortCut) of the specified index `idx`. 651 */ 652 void setItemShortcutDisabled(in long idx, in bool disabled) 653 { 654 checkClassBinding!(typeof(this))(); 655 ptrcall!(void)(GDNativeClassBinding.setItemShortcutDisabled, _godot_object, idx, disabled); 656 } 657 /** 658 Sets the submenu of the item at index `idx`. The submenu is the name of a child $(D PopupMenu) node that would be shown when the item is clicked. 659 */ 660 void setItemSubmenu(in long idx, in String submenu) 661 { 662 checkClassBinding!(typeof(this))(); 663 ptrcall!(void)(GDNativeClassBinding.setItemSubmenu, _godot_object, idx, submenu); 664 } 665 /** 666 Sets the text of the item at index `idx`. 667 */ 668 void setItemText(in long idx, in String text) 669 { 670 checkClassBinding!(typeof(this))(); 671 ptrcall!(void)(GDNativeClassBinding.setItemText, _godot_object, idx, text); 672 } 673 /** 674 Sets the $(D String) tooltip of the item at the specified index `idx`. 675 */ 676 void setItemTooltip(in long idx, in String tooltip) 677 { 678 checkClassBinding!(typeof(this))(); 679 ptrcall!(void)(GDNativeClassBinding.setItemTooltip, _godot_object, idx, tooltip); 680 } 681 /** 682 683 */ 684 void setSubmenuPopupDelay(in double seconds) 685 { 686 checkClassBinding!(typeof(this))(); 687 ptrcall!(void)(GDNativeClassBinding.setSubmenuPopupDelay, _godot_object, seconds); 688 } 689 /** 690 Toggles the check state of the item of the specified index `idx`. 691 */ 692 void toggleItemChecked(in long idx) 693 { 694 checkClassBinding!(typeof(this))(); 695 ptrcall!(void)(GDNativeClassBinding.toggleItemChecked, _godot_object, idx); 696 } 697 /** 698 Cycle to the next state of a multistate item. See $(D addMultistateItem) for details. 699 */ 700 void toggleItemMultistate(in long idx) 701 { 702 checkClassBinding!(typeof(this))(); 703 ptrcall!(void)(GDNativeClassBinding.toggleItemMultistate, _godot_object, idx); 704 } 705 /** 706 If `true`, allows navigating $(D PopupMenu) with letter keys. 707 */ 708 @property bool allowSearch() 709 { 710 return getAllowSearch(); 711 } 712 /// ditto 713 @property void allowSearch(bool v) 714 { 715 setAllowSearch(v); 716 } 717 /** 718 If `true`, hides the $(D PopupMenu) when a checkbox or radio button is selected. 719 */ 720 @property bool hideOnCheckableItemSelection() 721 { 722 return isHideOnCheckableItemSelection(); 723 } 724 /// ditto 725 @property void hideOnCheckableItemSelection(bool v) 726 { 727 setHideOnCheckableItemSelection(v); 728 } 729 /** 730 If `true`, hides the $(D PopupMenu) when an item is selected. 731 */ 732 @property bool hideOnItemSelection() 733 { 734 return isHideOnItemSelection(); 735 } 736 /// ditto 737 @property void hideOnItemSelection(bool v) 738 { 739 setHideOnItemSelection(v); 740 } 741 /** 742 If `true`, hides the $(D PopupMenu) when a state item is selected. 743 */ 744 @property bool hideOnStateItemSelection() 745 { 746 return isHideOnStateItemSelection(); 747 } 748 /// ditto 749 @property void hideOnStateItemSelection(bool v) 750 { 751 setHideOnStateItemSelection(v); 752 } 753 /** 754 755 */ 756 @property Array items() 757 { 758 return _getItems(); 759 } 760 /// ditto 761 @property void items(Array v) 762 { 763 _setItems(v); 764 } 765 /** 766 Sets the delay time in seconds for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item. 767 */ 768 @property double submenuPopupDelay() 769 { 770 return getSubmenuPopupDelay(); 771 } 772 /// ditto 773 @property void submenuPopupDelay(double v) 774 { 775 setSubmenuPopupDelay(v); 776 } 777 }