Picker

Choose a single item from a list of items.

Header#include "nativeui/picker.h"
Namespacenamespace nu
Typeclass (RefCounted)
InheritsView

By default, the first item is automatically selected, and duplicate items are merged into one.

Constructors

Picker()

Create a new Picker view.

Class properties

const char* kClassName

The class name of this view.

Methods

void AddItem(const std::string& title)

Add an item with title to the end.

Parameters

void RemoveItemAt(int index)

Remove the item at index.

Parameters

void Clear()

Remove all items.

std::vector<std::string> GetItems() const

Return all items.

Return

std::vector<std::string>

void SelectItemAt(int index)

Select the item at index.

Parameters

std::string GetSelectedItem() const

Return the title of selected item.

Empty string is returned if there is no selected item.

Return

std::string

int GetSelectedItemIndex() const

Return the index of selected item.

-1 is returned if there is no selected item.

Return

int

Events

void on_selection_change(Picker* self)

Emitted when user has changed the selected item.

Parameters

Preventable

No.