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
parentHudParentBase
Properties
BackgroundColor
Color used for the background behind the button pair
public Color BackgroundColor { get; set; }
Property Value
BackgroundPadding
Padding between background and button pair
public Vector2 BackgroundPadding { get; set; }
Property Value
BorderColor
Color of the border surrounding the on and off buttons
public Color BorderColor { get; set; }
Property Value
ButtonSpacing
Spacing between the on and off buttons
public float ButtonSpacing { get; set; }
Property Value
FocusColor
Focus color used for the background behind the button pair
public Color FocusColor { get; set; }
Property Value
FocusHandler
Interface for managing gaining/losing input focus
public IFocusHandler FocusHandler { get; }
Property Value
Format
Default glyph format used by the on and off buttons
public GlyphFormat Format { get; set; }
Property Value
HighlightColor
Highlight color used for the background behind the button pair
public Color HighlightColor { get; set; }
Property Value
HighlightEnabled
Determines whether or not the button will highlight when moused over.
public virtual bool HighlightEnabled { get; set; }
Property Value
MouseInput
Mouse input element for the button
public IMouseInput MouseInput { get; }
Property Value
OffText
Off button text
public RichText OffText { get; set; }
Property Value
OnText
On button text
public RichText OnText { get; set; }
Property Value
SelectionColor
Background color used to indicate the current selection
public Color SelectionColor { get; set; }
Property Value
UnselectedColor
Color used for the background of the unselected button
public Color UnselectedColor { get; set; }
Property Value
UpdateValueCallback
Registers a Value update callback. Useful in initializers.
public EventHandler UpdateValueCallback { set; }
Property Value
UseFocusFormatting
If true, then the button will change formatting when it takes focus.
public bool UseFocusFormatting { get; set; }
Property Value
Value
Current value of the on/off button
public bool Value { get; set; }
Property Value
Events
ValueChanged
Invoked when Value changes
public event EventHandler ValueChanged