Menu

Spark NumericStepper

SourceForge Editorial Staff

Spark NumericStepper - Functional and Design Specification


Summary and Background


NumericStepper is a Spinner that has a TextInput companion. It extends Spinner and adds a TextInput as a required SkinPart.

The numeric behavior of NumericStepper is exactly the same as Spinner. The scale is the same. The only additional behavior is that users may use the TextInput to edit the value.

Usage Scenarios


Allow users to specify a quantity either through the editable text field or to step the value via the arrow buttons.

Detailed Description


Behavior

See Spinner for detailed description of NumericStepper's behavior in terms of scale.

SkinParts

See Spinner for button SkinParts.

  • textDisplay - A TextInput that the user can use to change the value of the NumericStepper. Changes done through pressing the buttons and programmatically are also reflected by the TextInput.
Editing the Text Field

NumericStepper specifies an editable text field as a SkinPart called textDisplay. If textDisplay is edited, the new value is committed once the user performs an action that does not edit the text. These actions include:

  • Pressing the Enter key
  • Focusing out of the NumericStepper
  • Stepping either through the buttons or programmatically (calling changeValueByStep()).

The value of textDisplay is committed and then stepped regardless of whether changeValueByStep() is called programmatically or through user interaction.

Keyboard Behavior

Spinner's keyboard controls still apply (except for Left and Right since they navigate the textDisplay), but now, the text field can be edited. The value of the text field is committed whenever the user hits enter, focuses out of the NumericStepper using tab, or presses either of the buttons through up or down.

Events

Whenever the value changes, a "valueCommit" event is dispatched (inherited from Range).
Whenever the value changes because of user interaction, a "change" event is dispatched (inherited from Spinner).

Inherited Properties

value, minimum, maximum, snapInterval, stepSize - See Range.

allowValueWrap - See Spinner.

Properties

maxChars - The maximum number of characters that can be entered. If 0, then any number of characters can be entered.

valueFormatFunction - A callback function that formats the value to be displayed.

valueParseFunction - A callback function that extracts a numeric value from the textDisplay's text.

imeMode, enableIME - Properties that deal with setting IME mode and checking if IME is enabled.

Focus

textDisplay always has focus when NumericStepper is in focus.

API Description


package spark.components
{
//--------------------------------------
//  Styles
//--------------------------------------

include "../styles/metadata/BasicInheritingTextStyles.as"
include "../styles/metadata/AdvancedInheritingTextStyles.as"
include "../styles/metadata/SelectionFormatTextStyles.as"

/**
 *  The alpha of the border for this component.
 *
 *  @default 0.5
 */
<a href="Style%28name%3D%26quot%3BborderAlpha%26quot%3B%2C%20type%3D%26quot%3BNumber%26quot%3B%2C%20inherit%3D%26quot%3Bno%26quot%3B%2C%20theme%3D%26quot%3Bspark%26quot%3B%29">Style(name="borderAlpha", type="Number", inherit="no", theme="spark")</a>

/**
 *  The color of the border for this component.
 *
 *  @default 0x000000
 */
<a href="Style%28name%3D%26quot%3BborderColor%26quot%3B%2C%20type%3D%26quot%3Buint%26quot%3B%2C%20format%3D%26quot%3BColor%26quot%3B%2C%20inherit%3D%26quot%3Bno%26quot%3B%2C%20theme%3D%26quot%3Bspark%26quot%3B%29">Style(name="borderColor", type="uint", format="Color", inherit="no", theme="spark")</a>

/**
 *  Controls the visibility of the border for this component.
 *
 *  @default true
 */
<a href="Style%28name%3D%26quot%3BborderVisible%26quot%3B%2C%20type%3D%26quot%3BBoolean%26quot%3B%2C%20inherit%3D%26quot%3Bno%26quot%3B%2C%20theme%3D%26quot%3Bspark%26quot%3B%29">Style(name="borderVisible", type="Boolean", inherit="no", theme="spark")</a>

/**
 *  The alpha of the content background for this component.
 *
 *  @default 1
 */
<a href="Style%28name%3D%26quot%3BcontentBackgroundAlpha%26quot%3B%2C%20type%3D%26quot%3BNumber%26quot%3B%2C%20inherit%3D%26quot%3Byes%26quot%3B%2C%20theme%3D%26quot%3Bspark%26quot%3B%29">Style(name="contentBackgroundAlpha", type="Number", inherit="yes", theme="spark")</a>

/**
 *  @copy spark.components.supportClasses.GroupBase#style:contentBackgroundColor
 *
 *  @default 0xFFFFFF
 */
<a href="Style%28name%3D%26quot%3BcontentBackgroundColor%26quot%3B%2C%20type%3D%26quot%3Buint%26quot%3B%2C%20format%3D%26quot%3BColor%26quot%3B%2C%20inherit%3D%26quot%3Byes%26quot%3B%2C%20theme%3D%26quot%3Bspark%26quot%3B%29">Style(name="contentBackgroundColor", type="uint", format="Color", inherit="yes", theme="spark")</a>
/**
 *  The NumericStepper control lets you select
 *  a number from an ordered set.
 *  The NumericStepper provides the same functionality as
 *  the Spinner component, but adds a TextInput control
 *  so that you can directly edit the value of the component,
 *  rather than modifying it by using the control's arrow buttons.
 *
 *  <p>The NumericStepper control consists of a single-line
 *  input text field and a pair of arrow buttons
 *  for stepping through the possible values.
 *  The Up Arrow and Down Arrow keys and the mouse wheel also cycle through 
 *  the values. 
 *  An input value is committed when
 *  the user presses the Enter key, removes focus from the
 *  component, or steps the NumericStepper by pressing an arrow button
 *  or by calling the <code>changeValueByStep()</code> method.</p>
 *
 *  @see spark.components.Spinner
 *  @see spark.skins.spark.NumericStepperSkin
 *  @see spark.skins.spark.NumericStepperTextInputSkin
 */
public class NumericStepper extends Spinner 
    implements IFocusManagerComponent, IIMESupport
{
    include "../core/Version.as";

    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor
     */  
    public function NumericStepper();

    //--------------------------------------------------------------------------
    //
    // SkinParts
    //
    //--------------------------------------------------------------------------

    <a href="SkinPart%28required%3D%26quot%3Btrue%26quot%3B%29">SkinPart(required="true")</a>

    /**
     *  A skin part that defines a TextInput control 
     *  which allows a user to edit the value of
     *  the NumericStepper component. 
     *  The value is rounded and committed
     *  when the user presses enter, focuses out of
     *  the NumericStepper, or steps the NumericStepper.
     */
    public var textDisplay:TextInput;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  enableIME
    //----------------------------------

    /**
     *  A flag that indicates whether the IME should
     *  be enabled when the component receives focus.
     */
    public function get enableIME():Boolean;

    //----------------------------------
    //  maxChars
    //----------------------------------

    /**
     *  The maximum number of characters that can be entered in the field.
     *  A value of 0 means that any number of characters can be entered.
     *
     *  @default 0
     */
    public function get maxChars():int;
    public function set maxChars(value:int):void;


    //--------------------------------- 
    // valueFormatFunction
    //---------------------------------

    /**
     *  Callback function that formats the value displayed
     *  in the skin's <code>textDisplay</code> property.
     *  The function takes a single Number as an argument
     *  and returns a formatted String.
     *
     *  <p>The function has the following signature:</p>
     *  <pre>
     *  funcName(value:Number):String
     *  </pre>
     *
     *  @default undefined
     */
    public function get valueFormatFunction():Function;
    public function set valueFormatFunction(value:Function):void;

    //--------------------------------- 
    // valueParseFunction
    //---------------------------------

    /**
     *  Callback function that extracts the numeric 
     *  value from the displayed value in the 
     *  skin's <code>textDisplay</code> field.  
     * 
     *  The function takes a single String as an argument
     *  and returns a Number.
     *
     *  <p>The function has the following signature:</p>
     *  <pre>
     *  funcName(value:String):Number
     *  </pre>

     *  @default undefined   
     *  
     */
    public function get valueParseFunction():Function;
    public function set valueParseFunction(value:Function):void;

    //----------------------------------
    //  imeMode
    //----------------------------------

    /**
     *  Specifies the IME (Input Method Editor) mode.
     *  The IME enables users to enter text in Chinese, Japanese, and Korean.
     *  Flex sets the specified IME mode when the control gets the focus
     *  and sets it back to previous value when the control loses the focus.
     *
     * <p>The flash.system.IMEConversionMode class defines constants for the
     *  valid values for this property.
     *  You can also specify <code>null</code> to specify no IME.</p>
     *
     *  @see flash.system.IMEConversionMode
     *
     *  @default null
     */
    public function get imeMode():String;
    public function set imeMode(value:String):void;
}

}

B Features


QA


Yes


Related

Wiki: Flex 4
Wiki: Spark Range
Wiki: Spark Spinner

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.