class NumericStepper
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
implements IStageFocusDelegate, IRange
Select a value between a minimum and a maximum by using increment and decrement buttons or typing in a value in a text input.
The following example sets the stepper's range and listens for when the value changes:
var stepper = new NumericStepper();
stepper.minimum = 0.o;
stepper.maximum = 100.o;
stepper.step = 1.0;
stepper.value = 12.0;
stepper.addEventListener(Event.CHANGE, stepper_changeHandler);
addChild(stepper);
Events:
openfl.events.Event.CHANGE | Dispatched when |
---|
See also:
Static variables
staticfinalread onlyCHILD_VARIANT_DECREMENT_BUTTON:String = "numericStepper_decrementButton"
The variant used to style the decrement Button
child component in a theme.
To override this default variant, set the
NumericStepper.customDecrementButtonVariant
property.
1.0.0
.See also:
staticfinalread onlyCHILD_VARIANT_INCREMENT_BUTTON:String = "numericStepper_incrementButton"
The variant used to style the increment Button
child component in a theme.
To override this default variant, set the
NumericStepper.customIncrementButtonVariant
property.
1.0.0
.See also:
staticfinalread onlyCHILD_VARIANT_TEXT_INPUT:String = "numericStepper_textInput"
The variant used to style the TextInput
child component in a theme.
To override this default variant, set the
NumericStepper.customTextInputVariant
property.
1.0.0
.See also:
Constructor
new(value:Float = 0.0, minimum:Float = 0.0, maximum:Float = 1.0, ?changeListener:Event ‑> Void)
Creates a new NumericStepper
object with the given arguments.
1.0.0
.Variables
buttonDirection:Direction
How the buttons are positioned, relative to each other.
1.0.0
.buttonGap:Float
The space, in pixels, between buttons, if they are positioned next to each other.
1.1.0
.customDecrementButtonVariant:String
A custom variant to set on the decrement button, instead of
NumericStepper.CHILD_VARIANT_DECREMENT_BUTTON
.
The customDecrementButtonVariant
will be not be used if the result of
decrementButtonFactory
already has a variant set.
1.0.0
.See also:
customIncrementButtonVariant:String
A custom variant to set on the increment button, instead of
NumericStepper.CHILD_VARIANT_INCREMENT_BUTTON
.
The customIncrementButtonVariant
will be not be used if the result of
incrementButtonFactory
already has a variant set.
1.0.0
.See also:
customTextInputVariant:String
A custom variant to set on the text input, instead of
NumericStepper.CHILD_VARIANT_TEXT_INPUT
.
The customTextInputVariant
will be not be used if the result of
textInputFactory
already has a variant set.
1.0.0
.See also:
decrementButtonFactory:AbstractDisplayObjectFactory<Dynamic, Button>
Creates the decrement button, which must be of type
feathers.controls.Button
.
In the following example, a custom decrement button factory is provided:
stepper.decrementButtonFactory = () ->
{
return new Button();
};
1.0.0
.See also:
editable:Bool
Indicates if the text input is editable.
The following example disables editing:
textInput.editable = false;
1.0.0
.enableButtonsAtRangeLimits:Bool
Indicates if the decrement button is disabled when the value is equal to minimum, and if the increment button is disabled when the value is equal to the maximum.
If the buttons remain enabled, and the user attempts to decrement beyond the minimum, or increment beyond the maximum, triggering the button will have no effect, except visually.
The following example disables the buttons at range limits
textInput.enableButtonsAtRangeLimits = false;
1.2.0
.incrementButtonFactory:AbstractDisplayObjectFactory<Dynamic, Button>
Creates the increment button, which must be of type
feathers.controls.Button
.
In the following example, a custom increment button factory is provided:
stepper.incrementButtonFactory = () ->
{
return new Button();
};
1.0.0
.See also:
maximum:Float
The stepper's value cannot be larger than the maximum.
In the following example, the maximum is set to 100.0
:
stepper.minimum = 0.0;
stepper.maximum = 100.0;
stepper.step = 1.0;
stepper.value = 12.0;
1.0.0
.See also:
minimum:Float
The stepper's value cannot be smaller than the minimum.
In the following example, the minimum is set to -100.0
:
stepper.minimum = -100.0;
stepper.maximum = 100.0;
stepper.step = 1.0;
stepper.value = 50.0;
1.0.0
.See also:
snapInterval:Float
When the stepper's value
changes, it may be "snapped" to the nearest
multiple of snapInterval
. If snapInterval
is 0.0
, the value
is
not snapped.
In the following example, the snap inverval is changed to 1.0
:
stepper.minimum = 0.0;
stepper.maximum = 100.0;
stepper.step = 1.0;
stepper.snapInterval = 1.0;
stepper.value = 10.0;
1.0.0
.See also:
step:Float
Indicates the amount that value
is changed when the stepper has focus
and one of the arrow keys is pressed.
In the following example, the step is changed to 1.0
:
stepper.minimum = 0.0;
stepper.maximum = 100.0;
stepper.step = 1.0;
stepper.value = 10.0;
1.0.0
.See also:
textInputFactory:AbstractDisplayObjectFactory<Dynamic, TextInput>
Creates the text input, which must be of type
feathers.controls.TextInput
.
In the following example, a custom text input factory is provided:
stepper.textInputFactory = () ->
{
return new TextInput();
};
1.0.0
.See also:
textInputGap:Float
The space, in pixels, between the text input sub-component and other content.
1.1.0
.textInputPosition:HorizontalAlign
The horizontal position of the text input, relative to the buttons.
Note: The HorizontalAlign.JUSTIFY
constant is not supported by this
component.
1.0.0
.See also:
value:Float
The value of the stepper, which must be between the minimum
and the
maximum
.
When the value
property changes, the stepper will dispatch an event of
type Event.CHANGE
.
In the following example, the value is changed to 12.0
:
stepper.minimum = 0.0;
stepper.maximum = 100.0;
stepper.step = 1.0;
stepper.value = 12.0;
1.0.0
.See also:
valueFormatFunction:Float ‑> String
A callback that formats the numeric stepper's value as a string to display to the user.
In the following example, the stepper's value format function is customized:
stepper.valueFormatFunction = function(value:Float):String
{
return currencyFormatter.format(value, true);
};
1.0.0
.valueParseFunction:String ‑> Float
A callback that accepts the displayed text of the numeric stepper and
converts it to a simple Float
value.
In the following example, the stepper's value parse function is customized:
stepper.valueParseFunction = (displayedText:String):Float
{
return currencyFormatter.parse(displayedText).value;
};
@since 1.0.0
Methods
applyValueRestrictions():Void
Applies the minimum
, maximum
, and snapInterval
restrictions to the
current value
.
Because it's possible to set value
to a numeric value that is outside
the allowed range, or to a value that has not been snapped to the
interval, this method may be called to apply the restrictions manually.
1.0.0
.