[−][src]Struct gdnative_bindings::PopupMenu
core class PopupMenu
inherits Popup
(unsafe).
Official documentation
See the documentation of this class in the Godot engine's official documentation.
Memory management
Non reference counted objects such as the ones of this type are usually owned by the engine.
PopupMenu
is a reference-only type. Persistent references can
only exist in the unsafe Ref<PopupMenu>
form.
In the cases where Rust code owns an object of this type, for example if the object was just
created on the Rust side and not passed to the engine yet, ownership should be either given
to the engine or the object must be manually destroyed using Ref::free
, or Ref::queue_free
if it is a Node
.
Class hierarchy
PopupMenu inherits methods from:
Safety
All types in the Godot API have "interior mutability" in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
impl PopupMenu
[src]
pub fn new() -> Ref<Self, Unique>
[src]
Creates a new instance of this object.
Because this type is not reference counted, the lifetime of the returned object is not automatically managed.
Immediately after creation, the object is owned by the caller, and can be
passed to the engine (in which case the engine will be responsible for
destroying the object) or destroyed manually using Ref::free
, or preferably
Ref::queue_free
if it is a Node
.
pub fn add_check_item(&self, label: impl Into<GodotString>, id: i64, accel: i64)
[src]
Adds a new checkable item with text [code]label[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
[b]Note:[/b] 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.
Default Arguments
id
--1
accel
-0
pub fn add_check_shortcut(
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Adds a new checkable item and assigns the specified [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] 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.
Default Arguments
id
--1
global
-false
pub fn add_icon_check_item(
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
[src]
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
Adds a new checkable item with text [code]label[/code] and icon [code]texture[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
[b]Note:[/b] 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.
Default Arguments
id
--1
accel
-0
pub fn add_icon_check_shortcut(
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Adds a new checkable item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] 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.
Default Arguments
id
--1
global
-false
pub fn add_icon_item(
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
[src]
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
Adds a new item with text [code]label[/code] and icon [code]texture[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
Default Arguments
id
--1
accel
-0
pub fn add_icon_radio_check_item(
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
[src]
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
Same as [method add_icon_check_item], but uses a radio check button.
Default Arguments
id
--1
accel
-0
pub fn add_icon_radio_check_shortcut(
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Same as [method add_icon_check_shortcut], but uses a radio check button.
Default Arguments
id
--1
global
-false
pub fn add_icon_shortcut(
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
texture: impl AsArg<Texture>,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Adds a new item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
Default Arguments
id
--1
global
-false
pub fn add_item(&self, label: impl Into<GodotString>, id: i64, accel: i64)
[src]
Adds a new item with text [code]label[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
Default Arguments
id
--1
accel
-0
pub fn add_multistate_item(
&self,
label: impl Into<GodotString>,
max_states: i64,
default_state: i64,
id: i64,
accel: i64
)
[src]
&self,
label: impl Into<GodotString>,
max_states: i64,
default_state: i64,
id: i64,
accel: i64
)
Adds a new multistate item with text [code]label[/code].
Contrarily to normal binary items, multistate items can have more than two states, as defined by [code]max_states[/code]. Each press or activate of the item will increase the state by one. The default value is defined by [code]default_state[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
Default Arguments
default_state
-0
id
--1
accel
-0
pub fn add_radio_check_item(
&self,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
[src]
&self,
label: impl Into<GodotString>,
id: i64,
accel: i64
)
Adds a new radio check button with text [code]label[/code].
An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
[b]Note:[/b] 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.
Default Arguments
id
--1
accel
-0
pub fn add_radio_check_shortcut(
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Adds a new radio check button and assigns a [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
[b]Note:[/b] 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.
Default Arguments
id
--1
global
-false
pub fn add_separator(&self, label: impl Into<GodotString>)
[src]
pub fn add_shortcut(
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
[src]
&self,
shortcut: impl AsArg<ShortCut>,
id: i64,
global: bool
)
Adds a [ShortCut].
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
Default Arguments
id
--1
global
-false
pub fn add_submenu_item(
&self,
label: impl Into<GodotString>,
submenu: impl Into<GodotString>,
id: i64
)
[src]
&self,
label: impl Into<GodotString>,
submenu: impl Into<GodotString>,
id: i64
)
Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. The [code]submenu[/code] argument is the name of the child [PopupMenu] node that will be shown when the item is clicked.
An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
Default Arguments
id
--1
pub fn clear(&self)
[src]
Removes all items from the [PopupMenu].
pub fn allow_search(&self) -> bool
[src]
If [code]true[/code], allows to navigate [PopupMenu] with letter keys.
pub fn get_current_index(&self) -> i64
[src]
pub fn get_item_accelerator(&self, idx: i64) -> i64
[src]
Returns the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
pub fn get_item_count(&self) -> i64
[src]
Returns the number of items in the [PopupMenu].
pub fn get_item_icon(&self, idx: i64) -> Option<Ref<Texture, Shared>>
[src]
Returns the icon of the item at index [code]idx[/code].
pub fn get_item_id(&self, idx: i64) -> i64
[src]
Returns the id of the item at index [code]idx[/code]. [code]id[/code] can be manually assigned, while index can not.
pub fn get_item_index(&self, id: i64) -> i64
[src]
Returns the index of the item containing the specified [code]id[/code]. Index is automatically assigned to each item by the engine. Index can not be set manually.
pub fn get_item_metadata(&self, idx: i64) -> Variant
[src]
Returns the metadata of the specified item, which might be of any type. You can set it with [method set_item_metadata], which provides a simple way of assigning context data to items.
pub fn get_item_shortcut(&self, idx: i64) -> Option<Ref<ShortCut, Shared>>
[src]
Returns the [ShortCut] associated with the specified [code]idx[/code] item.
pub fn get_item_submenu(&self, idx: i64) -> GodotString
[src]
Returns the submenu name of the item at index [code]idx[/code]. See [method add_submenu_item] for more info on how to add a submenu.
pub fn get_item_text(&self, idx: i64) -> GodotString
[src]
Returns the text of the item at index [code]idx[/code].
pub fn get_item_tooltip(&self, idx: i64) -> GodotString
[src]
Returns the tooltip associated with the specified index index [code]idx[/code].
pub fn submenu_popup_delay(&self) -> f64
[src]
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.
pub fn is_hide_on_checkable_item_selection(&self) -> bool
[src]
If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected.
pub fn is_hide_on_item_selection(&self) -> bool
[src]
If [code]true[/code], hides the [PopupMenu] when an item is selected.
pub fn is_hide_on_state_item_selection(&self) -> bool
[src]
If [code]true[/code], hides the [PopupMenu] when a state item is selected.
pub fn is_hide_on_window_lose_focus(&self) -> bool
[src]
Returns [code]true[/code] if the popup will be hidden when the window loses focus or not.
pub fn is_item_checkable(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the item at index [code]idx[/code] is checkable in some way, i.e. if it has a checkbox or radio button.
[b]Note:[/b] Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually.
pub fn is_item_checked(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the item at index [code]idx[/code] is checked.
pub fn is_item_disabled(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the item at index [code]idx[/code] is disabled. When it is disabled it can't be selected, or its action invoked.
See [method set_item_disabled] for more info on how to disable an item.
pub fn is_item_radio_checkable(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the item at index [code]idx[/code] has radio button-style checkability.
[b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
pub fn is_item_separator(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the item is a separator. If it is, it will be displayed as a line. See [method add_separator] for more info on how to add a separator.
pub fn is_item_shortcut_disabled(&self, idx: i64) -> bool
[src]
Returns [code]true[/code] if the specified item's shortcut is disabled.
pub fn remove_item(&self, idx: i64)
[src]
Removes the item at index [code]idx[/code] from the menu.
[b]Note:[/b] The indices of items after the removed item will be shifted by one.
pub fn set_allow_search(&self, allow: bool)
[src]
If [code]true[/code], allows to navigate [PopupMenu] with letter keys.
pub fn set_hide_on_checkable_item_selection(&self, enable: bool)
[src]
If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected.
pub fn set_hide_on_item_selection(&self, enable: bool)
[src]
If [code]true[/code], hides the [PopupMenu] when an item is selected.
pub fn set_hide_on_state_item_selection(&self, enable: bool)
[src]
If [code]true[/code], hides the [PopupMenu] when a state item is selected.
pub fn set_hide_on_window_lose_focus(&self, enable: bool)
[src]
Hides the [PopupMenu] when the window loses focus.
pub fn set_item_accelerator(&self, idx: i64, accel: i64)
[src]
Sets the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
pub fn set_item_as_checkable(&self, idx: i64, enable: bool)
[src]
Sets whether the item at index [code]idx[/code] has a checkbox. If [code]false[/code], sets the type of the item to plain text.
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
pub fn set_item_as_radio_checkable(&self, idx: i64, enable: bool)
[src]
Sets the type of the item at the specified index [code]idx[/code] to radio button. If [code]false[/code], sets the type of the item to plain text.
pub fn set_item_as_separator(&self, idx: i64, enable: bool)
[src]
Mark the item at index [code]idx[/code] as a separator, which means that it would be displayed as a line. If [code]false[/code], sets the type of the item to plain text.
pub fn set_item_checked(&self, idx: i64, checked: bool)
[src]
Sets the checkstate status of the item at index [code]idx[/code].
pub fn set_item_disabled(&self, idx: i64, disabled: bool)
[src]
Enables/disables the item at index [code]idx[/code]. When it is disabled, it can't be selected and its action can't be invoked.
pub fn set_item_icon(&self, idx: i64, icon: impl AsArg<Texture>)
[src]
Replaces the [Texture] icon of the specified [code]idx[/code].
pub fn set_item_id(&self, idx: i64, id: i64)
[src]
Sets the [code]id[/code] of the item at index [code]idx[/code].
pub fn set_item_metadata(&self, idx: i64, metadata: impl OwnedToVariant)
[src]
Sets the metadata of an item, which may be of any type. You can later get it with [method get_item_metadata], which provides a simple way of assigning context data to items.
pub fn set_item_multistate(&self, idx: i64, state: i64)
[src]
Sets the state of an multistate item. See [method add_multistate_item] for details.
pub fn set_item_shortcut(
&self,
idx: i64,
shortcut: impl AsArg<ShortCut>,
global: bool
)
[src]
&self,
idx: i64,
shortcut: impl AsArg<ShortCut>,
global: bool
)
pub fn set_item_shortcut_disabled(&self, idx: i64, disabled: bool)
[src]
Disables the [ShortCut] of the specified index [code]idx[/code].
pub fn set_item_submenu(&self, idx: i64, submenu: impl Into<GodotString>)
[src]
Sets the submenu of the item at index [code]idx[/code]. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked.
pub fn set_item_text(&self, idx: i64, text: impl Into<GodotString>)
[src]
Sets the text of the item at index [code]idx[/code].
pub fn set_item_tooltip(&self, idx: i64, tooltip: impl Into<GodotString>)
[src]
Sets the [String] tooltip of the item at the specified index [code]idx[/code].
pub fn set_submenu_popup_delay(&self, seconds: f64)
[src]
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.
pub fn toggle_item_checked(&self, idx: i64)
[src]
Toggles the check state of the item of the specified index [code]idx[/code].
pub fn toggle_item_multistate(&self, idx: i64)
[src]
Cycle to the next state of an multistate item. See [method add_multistate_item] for details.
Methods from Deref<Target = Popup>
pub const NOTIFICATION_POPUP_HIDE: i64
[src]
pub const NOTIFICATION_POST_POPUP: i64
[src]
pub fn is_exclusive(&self) -> bool
[src]
If [code]true[/code], the popup will not be hidden when a click event occurs outside of it, or when it receives the [code]ui_cancel[/code] action event.
[b]Note:[/b] Enabling this property doesn't affect the Close or Cancel buttons' behavior in dialogs that inherit from this class. As a workaround, you can use [method WindowDialog.get_close_button] or [method ConfirmationDialog.get_cancel] and hide the buttons in question by setting their [member CanvasItem.visible] property to [code]false[/code].
pub fn popup(&self, bounds: Rect2)
[src]
pub fn popup_centered(&self, size: Vector2)
[src]
Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by [code]size[/code].
Default Arguments
size
-Vector2( 0, 0 )
pub fn popup_centered_clamped(&self, size: Vector2, fallback_ratio: f64)
[src]
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to [code]size[/code], then ensuring the popup is no larger than the viewport size multiplied by [code]fallback_ratio[/code].
Default Arguments
size
-Vector2( 0, 0 )
fallback_ratio
-0.75
pub fn popup_centered_minsize(&self, minsize: Vector2)
[src]
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than [code]minsize[/code].
Default Arguments
minsize
-Vector2( 0, 0 )
pub fn popup_centered_ratio(&self, ratio: f64)
[src]
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen.
Default Arguments
ratio
-0.75
pub fn set_as_minsize(&self)
[src]
Shrink popup to keep to the minimum size of content.
pub fn set_exclusive(&self, enable: bool)
[src]
If [code]true[/code], the popup will not be hidden when a click event occurs outside of it, or when it receives the [code]ui_cancel[/code] action event.
[b]Note:[/b] Enabling this property doesn't affect the Close or Cancel buttons' behavior in dialogs that inherit from this class. As a workaround, you can use [method WindowDialog.get_close_button] or [method ConfirmationDialog.get_cancel] and hide the buttons in question by setting their [member CanvasItem.visible] property to [code]false[/code].
Trait Implementations
impl Debug for PopupMenu
[src]
impl Deref for PopupMenu
[src]
impl DerefMut for PopupMenu
[src]
impl GodotObject for PopupMenu
[src]
type RefKind = ManuallyManaged
The memory management kind of this type. This modifies the behavior of the
Ref
smart pointer. See its type-level documentation for more
information. Read more
fn class_name() -> &'static str
[src]
fn null() -> Null<Self>
[src]
fn new() -> Ref<Self, Unique> where
Self: Instanciable,
[src]
Self: Instanciable,
fn cast<T>(&self) -> Option<&T> where
T: GodotObject + SubClass<Self>,
[src]
T: GodotObject + SubClass<Self>,
fn upcast<T>(&self) -> &T where
Self: SubClass<T>,
T: GodotObject,
[src]
Self: SubClass<T>,
T: GodotObject,
unsafe fn assume_shared(&self) -> Ref<Self, Shared>
[src]
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
[src]
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_unique(&self) -> Ref<Self, Unique>
[src]
impl Instanciable for PopupMenu
[src]
impl QueueFree for PopupMenu
[src]
unsafe fn godot_queue_free(obj: *mut godot_object)
[src]
impl Sealed for PopupMenu
[src]
impl SubClass<CanvasItem> for PopupMenu
[src]
impl SubClass<Control> for PopupMenu
[src]
impl SubClass<Node> for PopupMenu
[src]
impl SubClass<Object> for PopupMenu
[src]
impl SubClass<Popup> for PopupMenu
[src]
Auto Trait Implementations
impl RefUnwindSafe for PopupMenu
impl !Send for PopupMenu
impl !Sync for PopupMenu
impl Unpin for PopupMenu
impl UnwindSafe for PopupMenu
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SubClass<T> for T where
T: GodotObject,
[src]
T: GodotObject,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,