[][src]Struct gdnative::api::OptionButton

pub struct OptionButton { /* fields omitted */ }

core class OptionButton inherits Button (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.

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

impl OptionButton[src]

pub fn new() -> Ref<OptionButton, 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_icon_item(
    &self,
    texture: impl AsArg<Texture>,
    label: impl Into<GodotString>,
    id: i64
)
[src]

Adds an item, with a [code]texture[/code] icon, text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.

Default Arguments

  • id - -1

pub fn add_item(&self, label: impl Into<GodotString>, id: i64)[src]

Adds an item, with text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.

Default Arguments

  • id - -1

pub fn add_separator(&self)[src]

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.

pub fn clear(&self)[src]

Clears all the items in the [OptionButton].

pub fn get_item_count(&self) -> i64[src]

Returns the amount of items in the OptionButton, including separators.

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].

pub fn get_item_index(&self, id: i64) -> i64[src]

Returns the index of the item with the given [code]id[/code].

pub fn get_item_metadata(&self, idx: i64) -> Variant[src]

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.

pub fn get_item_text(&self, idx: i64) -> GodotString[src]

Returns the text of the item at index [code]idx[/code].

pub fn get_popup(&self) -> Option<Ref<PopupMenu, Shared>>[src]

Returns the [PopupMenu] contained in this button.

pub fn selected(&self) -> i64[src]

The index of the currently selected item, or [code]-1[/code] if no item is selected.

pub fn get_selected_id(&self) -> i64[src]

Returns the ID of the selected item, or [code]0[/code] if no item is selected.

pub fn get_selected_metadata(&self) -> Variant[src]

Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].

pub fn is_item_disabled(&self, idx: i64) -> bool[src]

Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.

pub fn remove_item(&self, idx: i64)[src]

Removes the item at index [code]idx[/code].

pub fn select(&self, idx: i64)[src]

Selects an item by index and makes it the current item. This will work even if the item is disabled.

pub fn set_item_disabled(&self, idx: i64, disabled: bool)[src]

Sets whether the item at index [code]idx[/code] 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.

pub fn set_item_icon(&self, idx: i64, texture: impl AsArg<Texture>)[src]

Sets the icon of the item at index [code]idx[/code].

pub fn set_item_id(&self, idx: i64, id: i64)[src]

Sets the ID 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. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.

pub fn set_item_text(&self, idx: i64, text: impl Into<GodotString>)[src]

Sets the text of the item at index [code]idx[/code].

Methods from Deref<Target = Button>

pub fn button_icon(&self) -> Option<Ref<Texture, Shared>>[src]

Button's icon, if text is present the icon will be placed before the text.

pub fn clip_text(&self) -> bool[src]

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.

pub fn text(&self) -> GodotString[src]

The button's text that will be displayed inside the button's area.

pub fn text_align(&self) -> TextAlign[src]

Text alignment policy for the button's text, use one of the [enum TextAlign] constants.

pub fn is_expand_icon(&self) -> bool[src]

When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.

pub fn is_flat(&self) -> bool[src]

Flat buttons don't display decoration.

pub fn set_button_icon(&self, texture: impl AsArg<Texture>)[src]

Button's icon, if text is present the icon will be placed before the text.

pub fn set_clip_text(&self, enabled: bool)[src]

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.

pub fn set_expand_icon(&self, arg0: bool)[src]

When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.

pub fn set_flat(&self, enabled: bool)[src]

Flat buttons don't display decoration.

pub fn set_text(&self, text: impl Into<GodotString>)[src]

The button's text that will be displayed inside the button's area.

pub fn set_text_align(&self, align: i64)[src]

Text alignment policy for the button's text, use one of the [enum TextAlign] constants.

Trait Implementations

impl Debug for OptionButton[src]

impl Deref for OptionButton[src]

type Target = Button

The resulting type after dereferencing.

impl DerefMut for OptionButton[src]

impl GodotObject for OptionButton[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

impl Instanciable for OptionButton[src]

impl QueueFree for OptionButton[src]

impl SubClass<BaseButton> for OptionButton[src]

impl SubClass<Button> for OptionButton[src]

impl SubClass<CanvasItem> for OptionButton[src]

impl SubClass<Control> for OptionButton[src]

impl SubClass<Node> for OptionButton[src]

impl SubClass<Object> for OptionButton[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.