SliderComponent
Classpublic class SliderComponent : MenuValueComponent<float>, IMenuComponentA selectable line carrying a number, drawn as a bar.
Takes over NavigateLeft and NavigateRight while it holds the selection; activating steps up by one Step.
View sourceConstructors
SliderComponent(string, float, float, float?, float, Action<MenuValueChangedContext<float>>?, string?)
Creates a slider.
public SliderComponent(string text = "", float min = 0, float max = 100, float? defaultValue = null, float step = 5, Action<MenuValueChangedContext<float>>? onChanged = null, string? id = null)- textstringoptionalThe label to display.
- minfloatoptionalThe lowest value.
- maxfloatoptionalThe highest value.
- defaultValuefloat?optionalThe value a player starts with, or null for min .
- stepfloatoptionalHow far one press moves the value.
- onChangedAction<MenuValueChangedContext<float>>?optionalRuns after the value changes.
- idstring?optionalA stable id, or null to generate one.
Properties
The bracket drawn after the bar.
public string ClosingBracket { get; set; }The colour of the closing bracket, or null to keep Style.
public string? ClosingBracketColor { get; set; }The character drawn for an empty segment.
public string EmptyChar { get; set; }The colour of the empty segments.
public string? EmptyColor { get; set; }The character drawn for a filled segment.
public string FilledChar { get; set; }The bracket drawn before the bar.
public string OpeningBracket { get; set; }The colour of the opening bracket, or null to keep Style.
public string? OpeningBracketColor { get; set; }Whether the number itself is shown next to the bar.
public bool ShowValue { get; set; }How far one press moves the value. Never zero or negative.
public float Step { get; set; }How many segments the bar is drawn with. Never below one.
public int TotalBars { get; set; }Whether stepping past either end continues from the other.
public bool WrapAround { get; set; }Methods
Adjusts a value before it is stored.
protected override float Coerce(IMenuSession session, float value)- sessionIMenuSessionThe session the value belongs to.
- valuefloatThe value being stored.
Used for clamping into a range or into the bounds of a list.
Offers an action to this component before the menu handles it.
public override ValueTask<bool> HandleActionAsync(MenuActionContext context)- contextMenuActionContextThe action being dispatched.
Only the focused component is offered actions. Returning true is how a component takes over a key that would otherwise navigate or close the menu.
Produces this component's renderer-agnostic output.
public override MenuNode Render(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe player and focus state to draw for.
Moves this player's value by one Step.
public bool StepValue(IMenuSession session, int direction)- sessionIMenuSessionThe session to move.
- directionintPositive to step up, negative to step down.