reckfellENGINE

OptionButton

Dropdown selection with separate row indices, IDs and item data.

On this page
class OptionButtonReckfellSharpInherits Button

OptionButton displays the selected item’s label. Add rows through AddItem/AddIconItem; the first available item is selected automatically without ItemSelected. AddSeparator creates a separator row and also increases ItemCount. Defaults are FitToLongestItem = true, AllowReselect = false and Selected = -1 before selection exists.

Do not confuse indices and IDs. Select, Selected and ItemSelected arguments use zero-based row indices, counting separators. GetSelectedId returns the assigned ID; GetItemIndex(id) finds its index or -1. Assign unique IDs yourself: automatic IDs come from creation-time indices and are not persistent keys when rebuilding lists. Metadata can hold application values independently of labels.

Select(index) does not emit ItemSelected, even with AllowReselect = true. To load a saved setting, call Select(GetItemIndex(savedId)) after checking the lookup result, then explicitly apply it to your model. Select(-1) clears selection and label; GetSelectedId returns -1 and GetSelectedMetadata returns Nil. Use nonnegative indices for other operations.

SetItemDisabled blocks user selection rather than programmatic Select: code can select a disabled row or separator. Check IsItemDisabled/IsItemSeparator before selecting in code. GetSelectableItem(false/true) finds the first/last available index rather than ID; returns -1 when none exists.

Explicitly restore selection after structural changes. Current RemoveItem does not decrement the saved index when removing an earlier row and can leave it out of bounds. The first SetItemCount after adding rows in code can also reset the index to -1 while a row remains checked. Save a stable ID before mutation, find it again afterward and call Select, or choose an available fallback. Do not read selected metadata/ID through a stale index.

ItemSelected reports the menu-selected index; ItemFocused reports a highlighted row rather than confirmation. AllowReselect permits repeat notification when selecting the same menu item again. FitToLongestItem accounts for all labels/icons and popup width; its cache refresh is deferred. false follows current button content and can change button width on selection.

GetPopup returns an internal PopupMenu owned by the button. Do not free or reparent it. Use OptionButton methods to edit rows: direct PopupMenu mutation can bypass label, selection and cache updates. SearchBarEnabled enables a search field; SearchBarMinItemCount sets a threshold counting nonseparator rows; fuzzy settings control matching with misses. These configure the menu rather than changing IDs or metadata.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

OptionButtonConstructor
# OptionButton
C#
public OptionButton();

Creates an empty selector: Selected = -1, FitToLongestItem = true, AllowReselect = false, ToggleMode = true, ActionMode = Press. PopupMenu is created as a hidden internal child.

Properties8

AllowReselectProperty
# AllowReselect
C#
public bool AllowReselect { get; set; }

Allows repeated ItemSelected for the same menu row, default false. Does not make Select emit the signal.

FitToLongestItemProperty
# FitToLongestItem
C#
public bool FitToLongestItem { get; set; }

Closed-button size accounts for all items and popup width, default true. Cache updates are deferred; false follows current label/icon and can change width on selection.

ItemCountProperty
# ItemCount
C#
public int ItemCount { get; set; }

Count of all rows including separators. Setter creates empty rows or truncates the tail; count must be nonnegative. First change after runtime additions can reset current index: explicitly Select afterward.

SearchBarEnabledProperty
# SearchBarEnabled
C#
public bool SearchBarEnabled { get; set; }

Enables popup search field, default false. Visibility also depends on SearchBarMinItemCount; does not select items or change IDs.

SearchBarFuzzySearchEnabledProperty
# SearchBarFuzzySearchEnabled
C#
public bool SearchBarFuzzySearchEnabled { get; set; }

Matching with permitted misses, default true. Does not itself enable the search field; allowed misses are configured separately.

SearchBarFuzzySearchMaxMissesProperty
# SearchBarFuzzySearchMaxMisses
C#
public int SearchBarFuzzySearchMaxMisses { get; set; }

Nonnegative maximum fuzzy-search misses, default 2. Not the visible result count.

SearchBarMinItemCountProperty
# SearchBarMinItemCount
C#
public int SearchBarMinItemCount { get; set; }

Nonnegative search visibility threshold counting nonseparator rows, default 0. Applies when SearchBarEnabled is on.

SelectedProperty
# Selected
C#
public int Selected { get; set; }

Current row index, -1 for no selection. Setter/Select do not emit ItemSelected and can select disabled/separator rows. Explicitly restore selection by stable ID after structural changes.

Methods44

AddIconItemvoid
# AddIconItem
C#
public void AddIconItem(Texture2D texture, string label, int id = -1);

Adds an item with shared Texture2D, label and ID. Automatic ID depends on creation-time index; first available row is selected without a signal.

Parameters
NameTypeDefault
textureTexture2D—
labelstring—
idint-1
texture

Adds an item with shared Texture2D, label and ID. Automatic ID depends on creation-time index; first available row is selected without a signal.

label

Adds an item with shared Texture2D, label and ID. Automatic ID depends on creation-time index; first available row is selected without a signal.

id

Item ID. On addition -1 uses creation-time index; for lookup supply a saved unique ID.

AddItemvoid
# AddItem
C#
public void AddItem(string label, int id = -1);

Adds a labeled item with an ID. id = -1 uses creation-time index. The first available item is selected without ItemSelected; index and ID need not match.

Parameters
NameTypeDefault
labelstring—
idint-1
label

Adds a labeled item with an ID. id = -1 uses creation-time index. The first available item is selected without ItemSelected; index and ID need not match.

id

Item ID. On addition -1 uses creation-time index; for lookup supply a saved unique ID.

AddSeparatorvoid
# AddSeparator
C#
public void AddSeparator(string text = "");

Adds a separator row with optional text. Increases ItemCount and affects following row indices; not an ordinary selectable item.

Parameters
NameTypeDefault
textstring""
text

Adds a separator row with optional text. Increases ItemCount and affects following row indices; not an ordinary selectable item.

Clearvoid
# Clear
C#
public void Clear();

Removes all rows, clears label/icon and sets Selected = -1. Does not emit ItemSelected.

GetAllowReselectbool
# GetAllowReselect
C#
public bool GetAllowReselect();

Allows repeated ItemSelected for the same menu row, default false. Does not make Select emit the signal.

Returns bool

true when menu reselection can repeat ItemSelected.

GetItemAutoTranslateModeEntity.AutoTranslateModeEnum
# GetItemAutoTranslateMode
C#
public Entity.AutoTranslateModeEnum GetItemAutoTranslateMode(int idx);

Item-label translation mode: Inherit, Always or Disabled. Setting the selected row refreshes its display. Does not translate IDs/metadata.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns Entity.AutoTranslateModeEnum

Stored item Entity.AutoTranslateModeEnum.

GetItemCountint
# GetItemCount
C#
public int GetItemCount();

Count of all rows including separators. Setter creates empty rows or truncates the tail; count must be nonnegative. First change after runtime additions can reset current index: explicitly Select afterward.

Returns int

Count of all rows including separators.

GetItemIconTexture2D
# GetItemIcon
C#
public Texture2D GetItemIcon(int idx);

Shared row Texture2D, or null; setting the selected row updates the closed-button icon.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns Texture2D

Shared row Texture2D, or null.

GetItemIdint
# GetItemId
C#
public int GetItemId(int idx);

Returns assigned row ID. idx = -1 returns -1 for no selection rather than the last row ID.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns int

Assigned ID rather than row index.

GetItemIndexint
# GetItemIndex
C#
public int GetItemIndex(int id);

Finds the first row with the ID; returns index or -1. IDs are not enforced unique, so assign unique application keys yourself.

Parameters
NameTypeDefault
idint—
id

Item ID. On addition -1 uses creation-time index; for lookup supply a saved unique ID.

Returns int

First matching ID’s index, or -1.

GetItemMetadataVariant
# GetItemMetadata
C#
public Variant GetItemMetadata(int idx);

Application Variant data independent of label and ID. Mutable resources/containers can remain shared.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns Variant

Row application Variant.

GetItemTextstring
# GetItemText
C#
public string GetItemText(int idx);

Source row label; setting the selected row updates the closed button. Item translation mode controls translation.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns string

Source row label.

GetItemTooltipstring
# GetItemTooltip
C#
public string GetItemTooltip(int idx);

Row tooltip in the popup. Not the selected-button label or selection data.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns string

Stored row tooltip text.

GetPopupPopupMenu
# GetPopup
C#
public PopupMenu GetPopup();

Returns shared internal PopupMenu. Do not free/reparent it. Edit rows through OptionButton methods to keep label, selection and cache consistent.

Returns PopupMenu

Shared internal PopupMenu owned by the button.

GetSearchBarFuzzySearchMaxMissesint
# GetSearchBarFuzzySearchMaxMisses
C#
public int GetSearchBarFuzzySearchMaxMisses();

Nonnegative maximum fuzzy-search misses, default 2. Not the visible result count.

Returns int

Stored SearchBarFuzzySearchMaxMisses setting.

GetSearchBarMinItemCountint
# GetSearchBarMinItemCount
C#
public int GetSearchBarMinItemCount();

Nonnegative search visibility threshold counting nonseparator rows, default 0. Applies when SearchBarEnabled is on.

Returns int

Stored SearchBarMinItemCount setting.

GetSelectableItemint
# GetSelectableItem
C#
public int GetSelectableItem(bool fromLast = false);

Finds first/last index excluding disabled/separator rows. Returns -1 if none exists. Does not select the row or return its ID.

Parameters
NameTypeDefault
fromLastboolfalse
fromLast

false for first available index, true for last.

Returns int

First/last available index, or -1.

GetSelectedint
# GetSelected
C#
public int GetSelected();

Current row index, -1 for no selection. Setter/Select do not emit ItemSelected and can select disabled/separator rows. Explicitly restore selection by stable ID after structural changes.

Returns int

Current index or -1; can be stale after removing an earlier row.

GetSelectedIdint
# GetSelectedId
C#
public int GetSelectedId();

Returns current row ID, or -1 for no selection. Restore a valid index after removing an earlier row; do not use stale Selected.

Returns int

Assigned selected-row ID, or -1 for no selection.

GetSelectedMetadataVariant
# GetSelectedMetadata
C#
public Variant GetSelectedMetadata();

Returns current row data, or Variant Nil with no selection. Explicitly restore selection first if list mutation may have left Selected stale.

Returns Variant

Selected-row Variant, or Nil for no selection.

HasSelectableItemsbool
# HasSelectableItems
C#
public bool HasSelectableItems();

Whether at least one row is neither disabled nor separator. Does not validate current Selected.

Returns bool

true when at least one enabled nonseparator item exists.

IsFitToLongestItembool
# IsFitToLongestItem
C#
public bool IsFitToLongestItem();

Closed-button size accounts for all items and popup width, default true. Cache updates are deferred; false follows current label/icon and can change width on selection.

Returns bool

true when minimum size accounts for all items/popup.

IsItemDisabledbool
# IsItemDisabled
C#
public bool IsItemDisabled(int idx);

Disables user selection of a row. Does not clear existing selection or block programmatic Select of that index.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns bool

true when the row is disabled for user selection.

IsItemSeparatorbool
# IsItemSeparator
C#
public bool IsItemSeparator(int idx);

Tests whether a row is a separator. Separators count toward ItemCount/indices but are skipped by GetSelectableItem.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Returns bool

true for a separator row.

IsSearchBarEnabledbool
# IsSearchBarEnabled
C#
public bool IsSearchBarEnabled();

Enables popup search field, default false. Visibility also depends on SearchBarMinItemCount; does not select items or change IDs.

Returns bool

Stored SearchBarEnabled setting.

IsSearchBarFuzzySearchEnabledbool
# IsSearchBarFuzzySearchEnabled
C#
public bool IsSearchBarFuzzySearchEnabled();

Matching with permitted misses, default true. Does not itself enable the search field; allowed misses are configured separately.

Returns bool

Stored SearchBarFuzzySearchEnabled setting.

RemoveItemvoid
# RemoveItem
C#
public void RemoveItem(int idx);

Removes a row by index. Removing the selected row clears selection. Current removal before the selected row does not decrement stored index; save its ID first and restore Select(GetItemIndex(id)) after checking the result.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

Selectvoid
# Select
C#
public void Select(int idx);

Selects an existing row index without ItemSelected; -1 clears selection. Do not pass an ID. Does not exclude disabled/separator rows or automatically update application state.

Parameters
NameTypeDefault
idxint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

SetAllowReselectvoid
# SetAllowReselect
C#
public void SetAllowReselect(bool allow);

Allows repeated ItemSelected for the same menu row, default false. Does not make Select emit the signal.

Parameters
NameTypeDefault
allowbool—
allow

Allows repeated ItemSelected for the same menu row, default false. Does not make Select emit the signal.

SetDisableShortcutsvoid
# SetDisableShortcuts
C#
public void SetDisableShortcuts(bool disabled);

Disables local list/base-button shortcut handling. Does not change application InputMap or disable ordinary Select/list methods.

Parameters
NameTypeDefault
disabledbool—
disabled

Disables local list/base-button shortcut handling. Does not change application InputMap or disable ordinary Select/list methods.

SetFitToLongestItemvoid
# SetFitToLongestItem
C#
public void SetFitToLongestItem(bool fit);

Closed-button size accounts for all items and popup width, default true. Cache updates are deferred; false follows current label/icon and can change width on selection.

Parameters
NameTypeDefault
fitbool—
fit

Closed-button size accounts for all items and popup width, default true. Cache updates are deferred; false follows current label/icon and can change width on selection.

SetItemAutoTranslateModevoid
# SetItemAutoTranslateMode
C#
public void SetItemAutoTranslateMode(int idx, Entity.AutoTranslateModeEnum mode);

Item-label translation mode: Inherit, Always or Disabled. Setting the selected row refreshes its display. Does not translate IDs/metadata.

Parameters
NameTypeDefault
idxint—
modeEntity.AutoTranslateModeEnum—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

mode

Item-label translation mode: Inherit, Always or Disabled. Setting the selected row refreshes its display. Does not translate IDs/metadata.

SetItemCountvoid
# SetItemCount
C#
public void SetItemCount(int count);

Count of all rows including separators. Setter creates empty rows or truncates the tail; count must be nonnegative. First change after runtime additions can reset current index: explicitly Select afterward.

Parameters
NameTypeDefault
countint—
count

Count of all rows including separators. Setter creates empty rows or truncates the tail; count must be nonnegative. First change after runtime additions can reset current index: explicitly Select afterward.

SetItemDisabledvoid
# SetItemDisabled
C#
public void SetItemDisabled(int idx, bool disabled);

Disables user selection of a row. Does not clear existing selection or block programmatic Select of that index.

Parameters
NameTypeDefault
idxint—
disabledbool—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

disabled

Disables user selection of a row. Does not clear existing selection or block programmatic Select of that index.

SetItemIconvoid
# SetItemIcon
C#
public void SetItemIcon(int idx, Texture2D texture);

Shared row Texture2D, or null; setting the selected row updates the closed-button icon.

Parameters
NameTypeDefault
idxint—
textureTexture2D—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

texture

Shared row Texture2D, or null; setting the selected row updates the closed-button icon.

SetItemIdvoid
# SetItemId
C#
public void SetItemId(int idx, int id);

Sets an existing row ID without changing index. Uniqueness is not enforced; avoid duplicate IDs.

Parameters
NameTypeDefault
idxint—
idint—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

id

Item ID. On addition -1 uses creation-time index; for lookup supply a saved unique ID.

SetItemMetadatavoid
# SetItemMetadata
C#
public void SetItemMetadata(int idx, Variant metadata);

Application Variant data independent of label and ID. Mutable resources/containers can remain shared.

Parameters
NameTypeDefault
idxint—
metadataVariant—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

metadata

Application Variant data independent of label and ID. Mutable resources/containers can remain shared.

SetItemTextvoid
# SetItemText
C#
public void SetItemText(int idx, string text);

Source row label; setting the selected row updates the closed button. Item translation mode controls translation.

Parameters
NameTypeDefault
idxint—
textstring—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

text

Source row label; setting the selected row updates the closed button. Item translation mode controls translation.

SetItemTooltipvoid
# SetItemTooltip
C#
public void SetItemTooltip(int idx, string tooltip);

Row tooltip in the popup. Not the selected-button label or selection data.

Parameters
NameTypeDefault
idxint—
tooltipstring—
idx

Zero-based row index rather than ID; Select accepts -1 to clear. Use an existing nonnegative index for other mutations.

tooltip

Row tooltip in the popup. Not the selected-button label or selection data.

SetSearchBarEnabledvoid
# SetSearchBarEnabled
C#
public void SetSearchBarEnabled(bool enabled);

Enables popup search field, default false. Visibility also depends on SearchBarMinItemCount; does not select items or change IDs.

Parameters
NameTypeDefault
enabledbool—
enabled

Enables popup search field, default false. Visibility also depends on SearchBarMinItemCount; does not select items or change IDs.

SetSearchBarFuzzySearchEnabledvoid
# SetSearchBarFuzzySearchEnabled
C#
public void SetSearchBarFuzzySearchEnabled(bool enabled);

Matching with permitted misses, default true. Does not itself enable the search field; allowed misses are configured separately.

Parameters
NameTypeDefault
enabledbool—
enabled

Matching with permitted misses, default true. Does not itself enable the search field; allowed misses are configured separately.

SetSearchBarFuzzySearchMaxMissesvoid
# SetSearchBarFuzzySearchMaxMisses
C#
public void SetSearchBarFuzzySearchMaxMisses(int maxMisses);

Nonnegative maximum fuzzy-search misses, default 2. Not the visible result count.

Parameters
NameTypeDefault
maxMissesint—
maxMisses

Nonnegative maximum fuzzy-search misses, default 2. Not the visible result count.

SetSearchBarMinItemCountvoid
# SetSearchBarMinItemCount
C#
public void SetSearchBarMinItemCount(int count);

Nonnegative search visibility threshold counting nonseparator rows, default 0. Applies when SearchBarEnabled is on.

Parameters
NameTypeDefault
countint—
count

Nonnegative search visibility threshold counting nonseparator rows, default 0. Applies when SearchBarEnabled is on.

ShowPopupvoid
# ShowPopup
C#
public void ShowPopup();

Opens the list when a Viewport exists. Neither Select nor item confirmation. Direct calls bypass Press’s Disabled check; call for an active in-tree button.

Signals and events2

ItemFocusedEvent
# ItemFocused
C#
public event OptionButton.ItemFocusedEventHandler ItemFocused;

Highlighted row index, long in C#. Not confirmation and need not equal Selected.

Handler parameters
NameTypeDefault
indexlong—
index

Zero-based row index, long in the C# signal, not ID.

ItemSelectedEvent
# ItemSelected
C#
public event OptionButton.ItemSelectedEventHandler ItemSelected;

Menu-selected row index, long in C#. Not an ID. Select and automatic selection during addition do not emit it; AllowReselect controls same-row reselection.

Handler parameters
NameTypeDefault
indexlong—
index

Zero-based row index, long in the C# signal, not ID.

Theme properties

These are Theme resource keys, not C# properties. Use the matching Control GetTheme…() and AddTheme…Override() methods for each value type.

Key and typeDescription
arrow_margin
int

The horizontal space between the arrow icon and the right edge of the button.

Default: 4
modulate_arrow
int

If different than 0, the arrow icon will be modulated to the font color.

Default: 0
arrow
Texture2D

The arrow icon to be drawn on the right end of the button.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.