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
stylesheetStylesheetThe stylesheet to use for applying the style.
styleNamestringThe 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
styleNamestringThe 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
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
FixedNumberSize
Gets or sets a value indicating whether the spin button should use fixed-width number formatting.
public bool FixedNumberSize { get; set; }
Property Value
HorizontalAlignment
Gets or sets the horizontal alignment of the spin button. Default is Left.
public override HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
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
Integer
Gets or sets a value indicating whether the spin button should only accept integer values.
public bool Integer { get; set; }
Property Value
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
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
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
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
TextBox
Gets the text box widget that contains the spin button's text input.
[Browsable(false)]
public TextBox TextBox { get; }
Property Value
Value
Gets or sets the current numeric value of the spin button. Default is 0.0.
public float? Value { get; set; }
Property Value
VerticalAlignment
Gets or sets the vertical alignment of the spin button. Default is Top.
public override VerticalAlignment VerticalAlignment { get; set; }
Property Value
Methods
ApplyStyle(WidgetStyle)
Applies the specified widget style to this spin button.
protected override void ApplyStyle(WidgetStyle style)
Parameters
styleWidgetStyleThe widget style to apply.
CopyFrom(Widget)
Copies the properties from another spin button widget.
protected override void CopyFrom(Widget w)
Parameters
wWidgetThe 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
ccharThe 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
kKeysThe 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
deltafloatThe 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
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
ValueChanging
Occurs before the value is changed. Set Cancel to true to prevent the change.
public event MyraEventHandler<ValueChangingEventArgs<float?>> ValueChanging