Skip to content

SliderWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A slider widget for selecting numeric values within a range.

csharp
public sealed record SliderWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SliderWidget>

Inheritance

ObjectHex1bWidgetSliderWidget

Implements

Properties

InitialValue

The initial value when the slider is first created.

Returns: Double

csharp
public double InitialValue { get; init; }

LargeStepPercent

The large step increment for PageUp/PageDown navigation, as a percentage of the range.

Returns: Double

csharp
public double LargeStepPercent { get; init; }

Maximum

The maximum value of the slider range.

Returns: Double

csharp
public double Maximum { get; init; }

Minimum

The minimum value of the slider range.

Returns: Double

csharp
public double Minimum { get; init; }

Step

The step increment for keyboard navigation.

Returns: Nullable<Double>

csharp
public double? Step { get; init; }

Methods

OnValueChanged(Action<SliderValueChangedEventArgs>)

Sets a synchronous handler called when the value changes. This is called for all input types: keyboard, click, drag, and scroll wheel.

Parameters:

Returns: SliderWidget

A new SliderWidget with the handler configured.

csharp
public SliderWidget OnValueChanged(Action<SliderValueChangedEventArgs> handler)

OnValueChanged(Func<SliderValueChangedEventArgs, Task>)

Sets an asynchronous handler called when the value changes. This is called for all input types: keyboard, click, drag, and scroll wheel.

Parameters:

Returns: SliderWidget

A new SliderWidget with the handler configured.

csharp
public SliderWidget OnValueChanged(Func<SliderValueChangedEventArgs, Task> handler)

Fields

DecreaseLargeActionId

Action ID for decreasing the slider value by a large step.

Returns: ActionId

csharp
public static readonly ActionId DecreaseLargeActionId

DecreaseSmallActionId

Action ID for decreasing the slider value by a small step.

Returns: ActionId

csharp
public static readonly ActionId DecreaseSmallActionId

IncreaseLargeActionId

Action ID for increasing the slider value by a large step.

Returns: ActionId

csharp
public static readonly ActionId IncreaseLargeActionId

IncreaseSmallActionId

Action ID for increasing the slider value by a small step.

Returns: ActionId

csharp
public static readonly ActionId IncreaseSmallActionId

JumpToMaximumActionId

Action ID for jumping to the maximum value.

Returns: ActionId

csharp
public static readonly ActionId JumpToMaximumActionId

JumpToMinimumActionId

Action ID for jumping to the minimum value.

Returns: ActionId

csharp
public static readonly ActionId JumpToMinimumActionId

SetValueActionId

Action ID for setting the slider value via mouse click.

Returns: ActionId

csharp
public static readonly ActionId SetValueActionId

Remarks

The slider displays a horizontal track with a movable handle. Users can adjust the value using keyboard controls or mouse clicks on the track.

Keyboard controls:

Left/Down arrow: Decrease value by stepRight/Up arrow: Increase value by stepHome: Jump to minimum valueEnd: Jump to maximum valuePageUp: Increase by large step (10% of range)PageDown: Decrease by large step (10% of range)

The slider state (current value) is owned by the node and preserved across re-renders. Use to set the starting value when the slider is first created.

Examples

Simple slider (0-100):

csharp
ctx.Slider(50)
    .OnValueChanged(e => Console.WriteLine($"Value: {e.Value}"));

Custom range with step:

csharp
ctx.Slider(initialValue: 25, min: 0, max: 100, step: 5)

Released under the MIT License.