Struct gdnative_bindings_lily::OptionButton [−][src]
pub struct OptionButton { /* fields omitted */ }
Expand description
core class OptionButton
inherits Button
(unsafe).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
Memory management
Non reference counted objects such as the ones of this type are usually owned by the engine.
OptionButton
is a reference-only type. Persistent references can
only exist in the unsafe Ref<OptionButton>
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
OptionButton 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
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_icon_item(
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64
)
pub fn add_icon_item(
&self,
texture: impl AsArg<Texture>,
label: impl Into<GodotString>,
id: i64
)
Adds an item, with a texture
icon, text label
and (optionally) id
. If no id
is passed, the item index will be used as the item’s ID. New items are appended at the end.
Default Arguments
id
--1
Adds an item, with text label
and (optionally) id
. If no id
is passed, the item index will be used as the item’s ID. New items are appended at the end.
Default Arguments
id
--1
Adds a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.
Clears all the items in the OptionButton.
Returns the amount of items in the OptionButton, including separators.
Returns the icon of the item at index idx
.
Returns the ID of the item at index idx
.
Returns the index of the item with the given id
.
Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
Returns the text of the item at index idx
.
Returns the PopupMenu contained in this button.
The index of the currently selected item, or -1
if no item is selected.
Returns the ID of the selected item, or 0
if no item is selected.
Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
Returns true
if the item at index idx
is disabled.
Removes the item at index idx
.
Selects an item by index and makes it the current item. This will work even if the item is disabled.
Sets whether the item at index idx
is disabled.
Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected.
Sets the icon of the item at index idx
.
Sets the ID of the item at index idx
.
Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
Sets the text of the item at index idx
.
Methods from Deref<Target = Button>
Button’s icon, if text is present the icon will be placed before the text.
When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
The button’s text that will be displayed inside the button’s area.
Text alignment policy for the button’s text, use one of the [enum TextAlign] constants.
When enabled, the button’s icon will expand/shrink to fit the button’s size while keeping its aspect.
Button’s icon, if text is present the icon will be placed before the text.
When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
When enabled, the button’s icon will expand/shrink to fit the button’s size while keeping its aspect.
The button’s text that will be displayed inside the button’s area.
Text alignment policy for the button’s text, use one of the [enum TextAlign] constants.
Trait Implementations
type RefKind = ManuallyManaged
type RefKind = ManuallyManaged
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for OptionButton
impl !Send for OptionButton
impl !Sync for OptionButton
impl Unpin for OptionButton
impl UnwindSafe for OptionButton