Table of Contents

Class BindInputElement

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

Attaches custom control-bind (key/combo) event handling to a UI element. Allows arbitrary IBind definitions to trigger NewPressed/PressedAndHeld/Released events on a specific UI node, optionally requiring input focus.

public class BindInputElement : HudNodeBase, IReadOnlyHudNode, IReadOnlyHudParent, IBindInput, IFocusableElement, IEnumerable<IBindEventProxy>, IEnumerable
Inheritance
BindInputElement
Implements
Inherited Members

Examples

This example demonstrates how to use a BindInputElement to add keyboard scrolling to a SliderBar. Collection initializer syntax is used to map the LeftArrow and RightArrow directly to handler methods.

public static void CreateSlider(HudParentBase parent)
{
    var slider = new SliderBar(parent)
    {
        Vertical = false,
        Min = 0f, Max = 100f, Value = 50f
    };

    var input = new BindInputElement(slider)
    {
        // Declarative registration of binds and callbacks
        CollectionInitializer = 
        {
            // Format: { IBind, NewPressed, PressedAndHeld, Released (null) }
            { SharedBinds.LeftArrow, OnSliderLeftArrow, OnSliderLeftArrow },
            { SharedBinds.RightArrow, OnSliderRightArrow, OnSliderRightArrow }
        }
    };
}

private static void OnSliderLeftArrow(object sender, EventArgs e)
{
    // The sender is the InputOwner (the SliderBar), not the BindInputElement
    var slider = (SliderBar)sender;
    slider.Value -= 1f;
}

private static void OnSliderRightArrow(object sender, EventArgs e)
{
    var slider = (SliderBar)sender;
    slider.Value += 1f;
}

Alternate Initialization

This demonstrates an alternative initialization pattern. Instead of using the collection initializer, the specific IBindEventProxy objects are retrieved using the class indexer. This approach is useful when adding binds dynamically after the object has been constructed or when more explicit syntax is desired.

var input = new BindInputElement(slider) { IsFocusRequired = false };

// Retrieve the event proxy for the Left Arrow bind
IBindEventProxy leftProxy = input[SharedBinds.LeftArrow];

// Subscribe to events
leftProxy.NewPressed += OnSliderLeftArrow;
leftProxy.PressedAndHeld += OnSliderLeftArrow;

// Retrieve and subscribe for the Right Arrow bind
IBindEventProxy rightProxy = input[SharedBinds.RightArrow];
rightProxy.NewPressed += OnSliderRightArrow;
rightProxy.PressedAndHeld += OnSliderRightArrow;

Remarks

BindInputElement functions as a specialized logic node that bridges IBind input with the UI system. Events triggered by this element (such as NewPressed or PressedAndHeld) will only fire if the parent UI node is currently Visible and has InputEnabled set to true. This ensures that keybinds do not trigger actions when the UI is hidden or disabled.

Constructors

BindInputElement(HudParentBase)

public BindInputElement(HudParentBase parent = null)

Parameters

parent HudParentBase

Properties

CollectionInitializer

Allows the addition of binds in conjunction with normal property initialization

public IBindInput CollectionInitializer { get; }

Property Value

IBindInput

FocusHandler

Element that owns this input, used for event callbacks

public IFocusHandler FocusHandler { get; protected set; }

Property Value

IFocusHandler

InputFilter

If set, the input groups indicated by the flags will be temporarily blocked until the BintInputElement is disabled.

Uses RequestTempBlacklist(SeBlacklistModes).

public SeBlacklistModes InputFilter { get; set; }

Property Value

SeBlacklistModes

InputPredicate

If defined, bind events will only fire when the predicate returns true.

public Func<bool> InputPredicate { get; set; }

Property Value

Func<bool>

IsFocusRequired

If true, bind events will only fire when the parent element has input focus. Default = false.

Only applies if the parent/InputOwner implements IFocusableElement.

public bool IsFocusRequired { get; set; }

Property Value

bool

this[IBind]

Retrieves the event proxy (press/release events) for a specific bind on this UI element

public IBindEventProxy this[IBind bind] { get; }

Parameters

bind IBind

Property Value

IBindEventProxy

Methods

Add(IBind, EventHandler, EventHandler, EventHandler)

Adds a bind (if not already present) and/or subscribes the provided event handlers. Multiple calls with the same bind are allowed and will stack handlers.

public void Add(IBind bind, EventHandler NewPressed = null, EventHandler PressedAndHeld = null, EventHandler Released = null)

Parameters

bind IBind
NewPressed EventHandler
PressedAndHeld EventHandler
Released EventHandler

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<IBindEventProxy> GetEnumerator()

Returns

IEnumerator<IBindEventProxy>

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

GetHasBind(IBind)

Returns true if the given bind is actively used and handled by this element

public bool GetHasBind(IBind bind)

Parameters

bind IBind

Returns

bool

Reset()

Removes all binds from the element

public void Reset()

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.