Skip to content

OptionButton

eduardgushchin edited this page Oct 22, 2026 · 1 revision

Home | API by Category | Complete API Index | API Status

Field Value
Full name Electron2D.OptionButton
Namespace Electron2D
Kind class
Category API Rendering

Overview

Displays one selected item and opens an owned themed dropdown menu.

Syntax

public class Electron2D.OptionButton

Remarks

The internal popup owns item records and borrows icons/shortcuts. IDs are independent of indices; metadata uses exact generic types and remains runtime-only. Programmatic selection emits no ItemSelected. An active embedded or native desktop host is required for dropdown presentation. Transparent native menus require the compatibility renderer; an opaque borrowed popup also executes with the GPU backend. Mutations follow scene ownership.

Inherits: Button

Detailed engine reference

Members

Member Kind Summary
public OptionButton() constructor Creates an empty toggle button with leading alignment, press-edge activation and an internal menu.
public OptionButton(System.String text) constructor Creates an empty choice button with initial source text.
public event System.Action<System.Int32> ItemFocused event Occurs after keyboard/controller navigation focuses a menu item, carrying its first matching ID index.
public event System.Action<System.Int32> ItemSelected event Occurs after a user activation commits the selected index and caption.
public System.Void AddIconItem(Electron2D.Texture icon, System.String label, System.Int32 id = -1) method Adds a radio item with a borrowed icon.
public System.Void AddItem(System.String label, System.Int32 id = -1) method Adds a radio item, selecting it if it is the first selectable record.
public System.Void AddSeparator(System.String text = "") method Adds a nonselectable separator with an optional source title.
public System.Void Clear() method Clears item records, selection and caption without ItemSelected.
protected override System.Func<Electron2D.Node> CreateSceneInstanceFactory() method
protected override System.Void Dispose(System.Boolean disposing) method
public Electron2D.NodeAutoTranslateMode GetItemAutoTranslateMode(System.Int32 index) method Gets an item's AutoTranslateMode value.
public System.Int32 GetItemID(System.Int32 index) method Gets an item's ID value.
public Electron2D.Texture GetItemIcon(System.Int32 index) method Gets an item's Icon value.
public System.Int32 GetItemIndex(System.Int32 id) method Gets the first record index with an exact ID.
public T GetItemMetadata<T>(System.Int32 index) method Gets runtime metadata with its exact generic type.
public System.String GetItemText(System.Int32 index) method Gets an item's Text value.
public System.String GetItemTooltip(System.Int32 index) method Gets an item's Tooltip value.
public Electron2D.PopupMenu GetPopup() method Gets the stable borrowed internal popup. Its lifetime remains owned by this button.
protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors() method
public System.Int32 GetSelectableItem(System.Boolean fromLast = false) method Finds the first or last enabled nonseparator record.
public System.Int32 GetSelectedID() method Gets the current signed ID, or -1 without selection.
public T GetSelectedMetadata<T>() method Gets selected exact generic metadata.
public System.Boolean HasSelectableItems() method Reports whether any record is enabled and not a separator.
public System.Boolean IsItemDisabled(System.Int32 index) method Reports an item's Disabled flag.
public System.Boolean IsItemSeparator(System.Int32 index) method Reports an item's Separator flag.
protected override Electron2D.Vector2 OnGetMinimumSize() method
protected override System.Void OnNotification(System.Int32 what) method
protected override System.Void OnPressed() method
protected override System.Void OnShortcutInput(Electron2D.InputEvent inputEvent) method
public System.Void RemoveItem(System.Int32 index) method Removes one record, retaining selection by identity or clearing a removed selection.
public System.Void Select(System.Int32 index) method Selects an existing record or clears selection, without ItemSelected.
public System.Void SetDisableShortcuts(System.Boolean disabled) method Disables this button's shortcut input stage, including popup item shortcuts.
public System.Void SetItemAutoTranslateMode(System.Int32 index, Electron2D.NodeAutoTranslateMode value) method Sets an item's AutoTranslateMode value and refreshes a selected caption/icon when applicable.
public System.Void SetItemDisabled(System.Int32 index, System.Boolean disabled) method Changes an enabled/disabled flag without changing programmatic selection.
public System.Void SetItemID(System.Int32 index, System.Int32 value) method Sets an item's ID value and refreshes a selected caption/icon when applicable.
public System.Void SetItemIcon(System.Int32 index, Electron2D.Texture value) method Sets an item's Icon value and refreshes a selected caption/icon when applicable.
public System.Void SetItemMetadata<T>(System.Int32 index, T value) method Sets exact generic runtime metadata.
public System.Void SetItemText(System.Int32 index, System.String value) method Sets an item's Text value and refreshes a selected caption/icon when applicable.
public System.Void SetItemTooltip(System.Int32 index, System.String value) method Sets an item's Tooltip value and refreshes a selected caption/icon when applicable.
public System.Void ShowPopup() method Opens the owned menu beneath the button; keyboard/programmatic opening focuses selection or the first selectable item.
public System.Boolean AllowReselect { get; set; } property Gets or sets whether activating the current item reports selection again.
public System.Boolean FitToLongestItem { get; set; } property Gets or sets whether the longest item and popup width contribute to the button minimum.
public System.Int32 ItemCount { get; set; } property Gets or sets the item count, retaining records and selected identity.
public System.Boolean SearchBarEnabled { get; set; } property Gets or sets the owned menu's SearchBarEnabled policy.
public System.Boolean SearchBarFuzzySearchEnabled { get; set; } property Gets or sets the owned menu's SearchBarFuzzySearchEnabled policy.
public System.Int32 SearchBarFuzzySearchMaxMisses { get; set; } property Gets or sets the owned menu's SearchBarFuzzySearchMaxMisses policy.
public System.Int32 SearchBarMinItemCount { get; set; } property Gets or sets the owned menu's SearchBarMinItemCount policy.
public System.Int32 Selected { get; set; } property Gets or sets the selected index without a user-selection event; an initial out-of-range assignment queues.

Member Details

OptionButton()

Kind: constructor

public OptionButton()

Summary

Creates an empty toggle button with leading alignment, press-edge activation and an internal menu.

OptionButton(System.String)

Kind: constructor

public OptionButton(System.String text)

Summary

Creates an empty choice button with initial source text.

Parameters

  • text: Nonnull text; later selection owns the caption.

ItemFocused

Kind: event

public event System.Action<System.Int32> ItemFocused

Summary

Occurs after keyboard/controller navigation focuses a menu item, carrying its first matching ID index.

ItemSelected

Kind: event

public event System.Action<System.Int32> ItemSelected

Summary

Occurs after a user activation commits the selected index and caption.

AddIconItem(Electron2D.Texture, System.String, System.Int32)

Kind: method

public System.Void AddIconItem(Electron2D.Texture icon, System.String label, System.Int32 id = -1)

Summary

Adds a radio item with a borrowed icon.

Parameters

  • icon: A live borrowed icon or null.
  • label: Nonnull source title.
  • id: Signed ID or -1 for automatic.

AddItem(System.String, System.Int32)

Kind: method

public System.Void AddItem(System.String label, System.Int32 id = -1)

Summary

Adds a radio item, selecting it if it is the first selectable record.

Parameters

  • label: Nonnull source title.
  • id: Signed ID; -1 derives from the new index.

AddSeparator(System.String)

Kind: method

public System.Void AddSeparator(System.String text = "")

Summary

Adds a nonselectable separator with an optional source title.

Parameters

  • text: Nonnull source title.

Clear()

Kind: method

public System.Void Clear()

Summary

Clears item records, selection and caption without ItemSelected.

CreateSceneInstanceFactory()

Kind: method

protected override System.Func<Electron2D.Node> CreateSceneInstanceFactory()

Dispose(System.Boolean)

Kind: method

protected override System.Void Dispose(System.Boolean disposing)

GetItemAutoTranslateMode(System.Int32)

Kind: method

public Electron2D.NodeAutoTranslateMode GetItemAutoTranslateMode(System.Int32 index)

Summary

Gets an item's AutoTranslateMode value.

Returns

The stored value; resources remain borrowed.

Parameters

  • index: A nonnegative index.

GetItemID(System.Int32)

Kind: method

public System.Int32 GetItemID(System.Int32 index)

Summary

Gets an item's ID value.

Returns

The stored value; resources remain borrowed.

Parameters

  • index: A nonnegative index; -1 returns -1.

GetItemIcon(System.Int32)

Kind: method

public Electron2D.Texture GetItemIcon(System.Int32 index)

Summary

Gets an item's Icon value.

Returns

The stored value; resources remain borrowed.

Parameters

  • index: A nonnegative index.

GetItemIndex(System.Int32)

Kind: method

public System.Int32 GetItemIndex(System.Int32 id)

Summary

Gets the first record index with an exact ID.

Returns

The first index or -1.

Parameters

  • id: The signed ID.

GetItemMetadata(System.Int32)

Kind: method

public T GetItemMetadata<T>(System.Int32 index)

Summary

Gets runtime metadata with its exact generic type.

Returns

The borrowed value.

Parameters

  • index: A nonnegative index.

GetItemText(System.Int32)

Kind: method

public System.String GetItemText(System.Int32 index)

Summary

Gets an item's Text value.

Returns

The stored value; resources remain borrowed.

Parameters

  • index: A nonnegative index.

GetItemTooltip(System.Int32)

Kind: method

public System.String GetItemTooltip(System.Int32 index)

Summary

Gets an item's Tooltip value.

Returns

The stored value; resources remain borrowed.

Parameters

  • index: A nonnegative index.

GetPopup()

Kind: method

public Electron2D.PopupMenu GetPopup()

Summary

Gets the stable borrowed internal popup. Its lifetime remains owned by this button.

Returns

The owned menu.

GetPropertyDescriptors()

Kind: method

protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors()

GetSelectableItem(System.Boolean)

Kind: method

public System.Int32 GetSelectableItem(System.Boolean fromLast = false)

Summary

Finds the first or last enabled nonseparator record.

Returns

The index or -1.

Parameters

  • fromLast: Searches backward when true.

GetSelectedID()

Kind: method

public System.Int32 GetSelectedID()

Summary

Gets the current signed ID, or -1 without selection.

Returns

The selected ID.

GetSelectedMetadata()

Kind: method

public T GetSelectedMetadata<T>()

Summary

Gets selected exact generic metadata.

Returns

The borrowed value.

Exceptions

  • T:System.Collections.Generic.KeyNotFoundException: Selection or matching metadata is absent.

HasSelectableItems()

Kind: method

public System.Boolean HasSelectableItems()

Summary

Reports whether any record is enabled and not a separator.

Returns

True when user selection is possible.

IsItemDisabled(System.Int32)

Kind: method

public System.Boolean IsItemDisabled(System.Int32 index)

Summary

Reports an item's Disabled flag.

Returns

The stored flag.

Parameters

  • index: A nonnegative index.

IsItemSeparator(System.Int32)

Kind: method

public System.Boolean IsItemSeparator(System.Int32 index)

Summary

Reports an item's Separator flag.

Returns

The stored flag.

Parameters

  • index: A nonnegative index.

OnGetMinimumSize()

Kind: method

protected override Electron2D.Vector2 OnGetMinimumSize()

OnNotification(System.Int32)

Kind: method

protected override System.Void OnNotification(System.Int32 what)

OnPressed()

Kind: method

protected override System.Void OnPressed()

OnShortcutInput(Electron2D.InputEvent)

Kind: method

protected override System.Void OnShortcutInput(Electron2D.InputEvent inputEvent)

RemoveItem(System.Int32)

Kind: method

public System.Void RemoveItem(System.Int32 index)

Summary

Removes one record, retaining selection by identity or clearing a removed selection.

Parameters

  • index: A nonnegative index.

Select(System.Int32)

Kind: method

public System.Void Select(System.Int32 index)

Summary

Selects an existing record or clears selection, without ItemSelected.

Parameters

  • index: A nonnegative existing index or -1.

SetDisableShortcuts(System.Boolean)

Kind: method

public System.Void SetDisableShortcuts(System.Boolean disabled)

Summary

Disables this button's shortcut input stage, including popup item shortcuts.

Parameters

  • disabled: Whether shortcut handling is disabled.

SetItemAutoTranslateMode(System.Int32, Electron2D.NodeAutoTranslateMode)

Kind: method

public System.Void SetItemAutoTranslateMode(System.Int32 index, Electron2D.NodeAutoTranslateMode value)

Summary

Sets an item's AutoTranslateMode value and refreshes a selected caption/icon when applicable.

Parameters

  • index: An index, optionally counted from the end.
  • value: The new typed value.

SetItemDisabled(System.Int32, System.Boolean)

Kind: method

public System.Void SetItemDisabled(System.Int32 index, System.Boolean disabled)

Summary

Changes an enabled/disabled flag without changing programmatic selection.

Parameters

  • index: An index, optionally negative.
  • disabled: The flag.

SetItemID(System.Int32, System.Int32)

Kind: method

public System.Void SetItemID(System.Int32 index, System.Int32 value)

Summary

Sets an item's ID value and refreshes a selected caption/icon when applicable.

Parameters

  • index: An index, optionally counted from the end.
  • value: The new typed value.

SetItemIcon(System.Int32, Electron2D.Texture)

Kind: method

public System.Void SetItemIcon(System.Int32 index, Electron2D.Texture value)

Summary

Sets an item's Icon value and refreshes a selected caption/icon when applicable.

Parameters

  • index: An index, optionally counted from the end.
  • value: The new typed value.

SetItemMetadata(System.Int32, T)

Kind: method

public System.Void SetItemMetadata<T>(System.Int32 index, T value)

Summary

Sets exact generic runtime metadata.

Parameters

  • index: An index, optionally counted from the end.
  • value: The borrowed value, including typed null.

SetItemText(System.Int32, System.String)

Kind: method

public System.Void SetItemText(System.Int32 index, System.String value)

Summary

Sets an item's Text value and refreshes a selected caption/icon when applicable.

Parameters

  • index: An index, optionally counted from the end.
  • value: The new typed value.

SetItemTooltip(System.Int32, System.String)

Kind: method

public System.Void SetItemTooltip(System.Int32 index, System.String value)

Summary

Sets an item's Tooltip value and refreshes a selected caption/icon when applicable.

Parameters

  • index: An index, optionally counted from the end.
  • value: The new typed value.

ShowPopup()

Kind: method

public System.Void ShowPopup()

Summary

Opens the owned menu beneath the button; keyboard/programmatic opening focuses selection or the first selectable item.

Remarks

Detached buttons return without opening. Attached presentation uses its containing viewport and native or embedded host.

AllowReselect

Kind: property

public System.Boolean AllowReselect { get; set; }

Summary

Gets or sets whether activating the current item reports selection again.

Value

False initially.

FitToLongestItem

Kind: property

public System.Boolean FitToLongestItem { get; set; }

Summary

Gets or sets whether the longest item and popup width contribute to the button minimum.

Value

True initially.

ItemCount

Kind: property

public System.Int32 ItemCount { get; set; }

Summary

Gets or sets the item count, retaining records and selected identity.

Value

Zero through 65536; new slots use radio decoration and automatic IDs.

SearchBarEnabled

Kind: property

public System.Boolean SearchBarEnabled { get; set; }

Summary

Gets or sets the owned menu's SearchBarEnabled policy.

Value

Uses the PopupMenu default and validation.

SearchBarFuzzySearchEnabled

Kind: property

public System.Boolean SearchBarFuzzySearchEnabled { get; set; }

Summary

Gets or sets the owned menu's SearchBarFuzzySearchEnabled policy.

Value

Uses the PopupMenu default and validation.

SearchBarFuzzySearchMaxMisses

Kind: property

public System.Int32 SearchBarFuzzySearchMaxMisses { get; set; }

Summary

Gets or sets the owned menu's SearchBarFuzzySearchMaxMisses policy.

Value

Uses the PopupMenu default and validation.

SearchBarMinItemCount

Kind: property

public System.Int32 SearchBarMinItemCount { get; set; }

Summary

Gets or sets the owned menu's SearchBarMinItemCount policy.

Value

Uses the PopupMenu default and validation.

Selected

Kind: property

public System.Int32 Selected { get; set; }

Summary

Gets or sets the selected index without a user-selection event; an initial out-of-range assignment queues.

Value

-1 initially. Existing disabled/separator records may be selected programmatically.

Clone this wiki locally