Table of Contents

Class SpinButton

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

A spin button widget for entering numeric values with increment/decrement buttons.

public class SpinButton : Widget, IItemWithId, INotifyAttachedPropertyChanged
Inheritance
SpinButton
Implements
Inherited Members

Constructors

SpinButton(Stylesheet, string)

Initializes a new instance of the SpinButton class with the specified stylesheet and style.

public SpinButton(Stylesheet stylesheet, string styleName = "")

Parameters

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

SpinButton(string)

Initializes a new instance of the SpinButton class with the specified style.

public SpinButton(string styleName = "")

Parameters

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Properties

AcceptsMouseWheel

Gets a value indicating whether the spin button accepts mouse wheel input.

protected override bool AcceptsMouseWheel { get; }

Property Value

bool

DecimalPlaces

Gets or sets the number of decimal places to display for floating-point values. Default is 0.

public int DecimalPlaces { get; set; }

Property Value

int

FixedNumberSize

Gets or sets a value indicating whether the spin button should use fixed-width number formatting.

public bool FixedNumberSize { get; set; }

Property Value

bool

HorizontalAlignment

Gets or sets the horizontal alignment of the spin button. Default is Left.

public override HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

Increment

Gets or sets the amount to increment or decrement the value when using the up/down buttons. Default is 1.0.

public float Increment { get; set; }

Property Value

float

Integer

Gets or sets a value indicating whether the spin button should only accept integer values.

public bool Integer { get; set; }

Property Value

bool

Maximum

Gets or sets the maximum value allowed in the spin button, or null for no maximum limit.

public float? Maximum { get; set; }

Property Value

float?

Minimum

Gets or sets the minimum value allowed in the spin button, or null for no minimum limit.

public float? Minimum { get; set; }

Property Value

float?

Mul_Increment

Gets or sets the multiplier applied to the increment when using the mouse wheel. Default is 1.0.

public float Mul_Increment { get; set; }

Property Value

float

Nullable

Gets or sets a value indicating whether null is an acceptable value for this spin button. Default is false.

public bool Nullable { get; set; }

Property Value

bool

TextBox

Gets the text box widget that contains the spin button's text input.

[Browsable(false)]
public TextBox TextBox { get; }

Property Value

TextBox

Value

Gets or sets the current numeric value of the spin button. Default is 0.0.

public float? Value { get; set; }

Property Value

float?

VerticalAlignment

Gets or sets the vertical alignment of the spin button. Default is Top.

public override VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Methods

ApplyStyle(WidgetStyle)

Applies the specified widget style to this spin button.

protected override void ApplyStyle(WidgetStyle style)

Parameters

style WidgetStyle

The widget style to apply.

CopyFrom(Widget)

Copies the properties from another spin button widget.

protected override void CopyFrom(Widget w)

Parameters

w Widget

The source spin button widget to copy from.

OnChar(char)

Handles character input by delegating to the text box input.

public override void OnChar(char c)

Parameters

c char

The character being entered.

OnGotKeyboardFocus()

Handles gaining keyboard focus by delegating focus to the text box input.

public override void OnGotKeyboardFocus()

OnKeyDown(Keys)

Handles keyboard key down events by delegating to the text box input.

public override void OnKeyDown(Keys k)

Parameters

k Keys

The key being pressed.

OnLostKeyboardFocus()

Handles losing keyboard focus by delegating to the text box and applying a default value if needed.

public override void OnLostKeyboardFocus()

OnMouseWheel(float)

Handles mouse wheel input to adjust the spin button value when the wheel adjustment multiplier is applied.

public override void OnMouseWheel(float delta)

Parameters

delta float

The mouse wheel delta value (positive for up/forward, negative for down/back).

Events

ValueChanged

Occurs when the value changes, regardless of whether it was changed by user input or programmatically.

public event MyraEventHandler<ValueChangedEventArgs<float?>> ValueChanged

Event Type

MyraEventHandler<ValueChangedEventArgs<float?>>

ValueChangedByUser

Occurs when the value changes due to user interaction (buttons or mouse wheel). Does not fire for programmatic value changes.

public event MyraEventHandler<ValueChangedEventArgs<float?>> ValueChangedByUser

Event Type

MyraEventHandler<ValueChangedEventArgs<float?>>

ValueChanging

Occurs before the value is changed. Set Cancel to true to prevent the change.

public event MyraEventHandler<ValueChangingEventArgs<float?>> ValueChanging

Event Type

MyraEventHandler<ValueChangingEventArgs<float?>>