Table of Contents

Class SelectionBoxBase<TChain, TContainer, TElement>

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

Core abstract base class for selection box controls. Manages a list of entries, keyboard/mouse selection, highlighting, and visual feedback (selection box + highlight box).

public abstract class SelectionBoxBase<TChain, TContainer, TElement> : HudElementBase, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent, IEntryBox<TContainer, TElement>, IEnumerable<TContainer>, IEnumerable, IValueControl<TContainer>, IValueControl, IClickableElement, IFocusableElement where TChain : HudChain<TContainer, TElement>, new() where TContainer : class, ISelectionBoxEntry<TElement>, new() where TElement : HudElementBase, IMinLabelElement

Type Parameters

TChain

The concrete HudChain<TElementContainer, TElement> type used as the list container (e.g. HudChain<TElementContainer, TElement> or ScrollBox<TElementContainer, TElement>)

TContainer

Container type wrapping each entry

TElement

UI element type displayed inside each container

Inheritance
SelectionBoxBase<TChain, TContainer, TElement>
Implements
IEntryBox<TContainer, TElement>
IEnumerable<TContainer>
IValueControl<TContainer>
Derived
Inherited Members

Remarks

SelectionBoxBase is the foundational abstract class for all selection-style list controls. It combines standardized input handling with a ListInputElement<TElementContainer, TElement> component to deliver core functionality. This includes features such as highlighting, selection management, and entry hiding.

The list's layout and scrolling behavior are governed by the generic TChain parameter, which defines the underlying container. This container is typically a HudChain<TElementContainer, TElement> for non-scrolling lists or a ScrollBox<TElementContainer, TElement> for scrollable lists. In both cases, the container manages the collection of elements through a HudCollection<TElementContainer, TElement>.

Concrete Implementations

To simplify usage, each concrete implementation of SelectionBoxBase provides aliases for its default generic parameters (TElementContainer and TElement).

The primary specialization, SelectionBox<TChain, TContainer, TElement, TValue>, forms the basis for selection boxes that use reusable and uniform pooled entries. It offers two main variants based on the container type:

Additional derived types include:

Properties

Count

Number of entries in the list.

public int Count { get; }

Property Value

int

EntryList

Read-only access to the list of entry containers.

public IReadOnlyList<TContainer> EntryList { get; }

Property Value

IReadOnlyList<TContainer>

FocusColor

Background color of the selection overlay when the list has input focus.

public Color FocusColor { get; set; }

Property Value

Color

FocusHandler

Handles keyboard/mouse focus for the entire control.

public IFocusHandler FocusHandler { get; }

Property Value

IFocusHandler

FocusTextColor

Text color used for the currently focused entry (keyboard navigation).

public Color FocusTextColor { get; set; }

Property Value

Color

Format

Default text format applied to entry labels.

public GlyphFormat Format { get; set; }

Property Value

GlyphFormat

HighlightColor

Default background color of the highlight/selection overlay when not focused.

public Color HighlightColor { get; set; }

Property Value

Color

HighlightPadding

Additional padding applied inside the highlight/selection overlay.

public Vector2 HighlightPadding { get; set; }

Property Value

Vector2

IsMousedOver

True when the mouse cursor is over any part of the list.

public override bool IsMousedOver { get; }

Property Value

bool

ListContainer

Allows nested collection-initializer syntax (e.g., new MyListBox { ListContainer = { entry1, entry2 } });

public SelectionBoxBase<TChain, TContainer, TElement> ListContainer { get; }

Property Value

SelectionBoxBase<TChain, TContainer, TElement>

MouseInput

Mouse input handler for the list (used for hover/click detection).

public IMouseInput MouseInput { get; }

Property Value

IMouseInput

SelectionIndex

Index of the currently selected entry (-1 if none).

public int SelectionIndex { get; }

Property Value

int

TabColor

Color of the small vertical tab drawn on the left side of the highlight/selection box.

public Color TabColor { get; set; }

Property Value

Color

UpdateValueCallback

Convenience property for adding a selection callback during object initialization.

public EventHandler UpdateValueCallback { set; }

Property Value

EventHandler

Value

Currently selected entry, or null if nothing is selected.

public TContainer Value { get; }

Property Value

TContainer

Methods

ClearSelection()

Clears the current selection

public void ClearSelection()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<TContainer> GetEnumerator()

Returns

IEnumerator<TContainer>

An enumerator that can be used to iterate through the collection.

GetRangeSize(int, int)

Calculates the combined size of the list entries within the given index range.

public virtual Vector2 GetRangeSize(int start = 0, int end = -1)

Parameters

start int

Start index.

end int

End index (-1 for last element).

Returns

Vector2

Total size vector (Width, Height) required to fit the range.

OffsetSelectionIndex(int, bool)

Offsets selection index in the direction of the offset. If wrap == true, the index will wrap around if the offset places it out of range.

public void OffsetSelectionIndex(int offset, bool wrap = false)

Parameters

offset int
wrap bool

SetSelection(TContainer)

Sets the selection to the specified entry.

public void SetSelection(TContainer member)

Parameters

member TContainer

SetSelectionAt(int)

Sets the selection to the member associated with the given object.

public void SetSelectionAt(int index)

Parameters

index int

Events

ValueChanged

Raised when the selected entry changes.

public event EventHandler ValueChanged

Event Type

EventHandler

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IEnumerator IEnumerable.GetEnumerator()

Returns

IEnumerator

An IEnumerator object that can be used to iterate through the collection.