Table of Contents

Class OnOffButton

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

A pair of horizontally aligned on and off bordered buttons used to indicate a boolean value. Styled to resemble on/off button used in the SE terminal.

Does not have a label. Use NamedOnOffButton for a version with a label.

Formatting temporarily changes when it gains input focus.

public class OnOffButton : HudElementBase, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent, IClickableElement, IFocusableElement, IValueControl<bool>, IValueControl
Inheritance
OnOffButton
Implements
Inherited Members

Examples

This creates an unlabeled on/off toggle with custom label names, and prints the label corresponding to the selected value to chat when changed.

new OnOffButton(parent)
{
    OnText = "Mode 1",
    OffText = "Mode 2",
    UpdateValueCallback = (obj, args) => 
    {
        var toggle = (OnOffButton)obj;
        // Get mode string from boolean value
        string valStr = toggle.Value ? 
            toggle.OnText.ToString() : 
            toggle.OffText.ToString();
        // Write value to chat
        MyAPIGateway.Utilities.ShowMessage(
            $"[{toggle.GetType().Name}]", // Print toggle type
            $"Toggle Value: {valStr}");
    },
    MouseInput = 
    { 
        ToolTip = "This unlabeled toggle prints the mode name to chat."
    }
};

Constructors

OnOffButton()

public OnOffButton()

OnOffButton(HudParentBase)

public OnOffButton(HudParentBase parent)

Parameters

parent HudParentBase

Properties

BackgroundColor

Color used for the background behind the button pair

public Color BackgroundColor { get; set; }

Property Value

Color

BackgroundPadding

Padding between background and button pair

public Vector2 BackgroundPadding { get; set; }

Property Value

Vector2

BorderColor

Color of the border surrounding the on and off buttons

public Color BorderColor { get; set; }

Property Value

Color

ButtonSpacing

Spacing between the on and off buttons

public float ButtonSpacing { get; set; }

Property Value

float

FocusColor

Focus color used for the background behind the button pair

public Color FocusColor { get; set; }

Property Value

Color

FocusHandler

Interface for managing gaining/losing input focus

public IFocusHandler FocusHandler { get; }

Property Value

IFocusHandler

Format

Default glyph format used by the on and off buttons

public GlyphFormat Format { get; set; }

Property Value

GlyphFormat

HighlightColor

Highlight color used for the background behind the button pair

public Color HighlightColor { get; set; }

Property Value

Color

HighlightEnabled

Determines whether or not the button will highlight when moused over.

public virtual bool HighlightEnabled { get; set; }

Property Value

bool

MouseInput

Mouse input element for the button

public IMouseInput MouseInput { get; }

Property Value

IMouseInput

OffText

Off button text

public RichText OffText { get; set; }

Property Value

RichText

OnText

On button text

public RichText OnText { get; set; }

Property Value

RichText

SelectionColor

Background color used to indicate the current selection

public Color SelectionColor { get; set; }

Property Value

Color

UnselectedColor

Color used for the background of the unselected button

public Color UnselectedColor { get; set; }

Property Value

Color

UpdateValueCallback

Registers a Value update callback. Useful in initializers.

public EventHandler UpdateValueCallback { set; }

Property Value

EventHandler

UseFocusFormatting

If true, then the button will change formatting when it takes focus.

public bool UseFocusFormatting { get; set; }

Property Value

bool

Value

Current value of the on/off button

public bool Value { get; set; }

Property Value

bool

Events

ValueChanged

Invoked when Value changes

public event EventHandler ValueChanged

Event Type

EventHandler