Spark Spinner - Functional and Design SpecificationSpark Spinner - Functional and Design Specification | Glossary | Summary and Background | Usage Scenarios | Detailed Description | API Description | B Features | Additional Implementation Details | Prototype Work | Compiler Work | Web Tier Compiler Impact | Flex Feature Dependencies | Backwards Compatibility | Accessibility | Issues and Recommendations
Glossaryscale - See Range Summary and BackgroundThis specification describes the proposed new Spinner class which extends Range in Gumbo. Spinner extends from Range and adds two buttons as skin parts that allow someone to step the current value through its scale. NumericStepper will extend from Spinner. The primary motivations for adding this new class were:
By having the Spinner class, developers can be more flexible with the types of displays allowed. One can imagine having a Spinner controlling tabs or a menu by assigning different values to tabs or menu items. Also, NumericStepper was the only basic component that did not support accessibility. Spinner remedies this problem by allowing NumericStepper to be a spinner with the additional element of a [TextInput]. Usage Scenarios
Detailed DescriptionBehaviorSpinner controls a value through its two buttons, incrementButton and decrementButton. These buttons use stepSize to increment or decrement the values. SkinPartsSpinner is composed of two skin parts that are buttons:
Inherited Propertiesvalue, minimum, maximum, snapInterval, stepSize - See Range.
New PropertiesallowValueWrap - enables or disables value wrapping. The default is false. MethodsincrementButton_buttonDownHandler(), decrementButton_buttonDownHandler() - These protected methods handle the behavior of each button. system_mouseWheelHandler() - Handles mouse wheel events. EventsWhenever the value changes, a valueCommit event is dispatched (inherited from Range). Whenever the value changes because of user interaction, a change event is dispatched. Keyboard Behavior
API Descriptionpackage spark.components { //-------------------------------------- // Styles //-------------------------------------- /** * The radius of the corners of this component. * * @default 2 */ [Style(name="cornerRadius", type="Number", format="Length", inherit="no", theme="spark", minValue="0.0")] /** * The alpha of the focus ring for this component. * * @default 0.5 */ [Style(name="focusAlpha", type="Number", inherit="no", theme="spark", minValue="0.0", maxValue="1.0")] /** * @copy spark.components.supportClasses.GroupBase#style:focusColor * * @default 0x70B2EE */ [Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="spark")] /** * @copy spark.components.supportClasses.GroupBase#style:symbolColor * * @default 0x000000 */ [Style(name="symbolColor", type="uint", format="Color", inherit="yes", theme="spark")] //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when the value of the Spinner control changes * as a result of user interaction. * * @eventType flash.events.Event.CHANGE */ [Event(name="change", type="flash.events.Event")] //-------------------------------------- // Skin states //-------------------------------------- /** * Normal State */ [SkinState("normal")] /** * Disabled State */ [SkinState("disabled")] /** * A Spinner component selects a value from an * ordered set. It uses two buttons that increase or * decrease the current value based on the current * value of the <code>stepSize</code> property. * * <p>A Spinner consists of two required buttons, * one to increase the current value and one to decrease the * current value. Users can also use the Up Arrow and Down Arrow keys * and the mouse wheel to cycle through the values. * An input value is committed when the user presses the Enter key, * removes focus from the component, or steps the Spinner * by pressing an arrow button or by calling the * <code>changeValueByStep()</code> method.</p> * * <p>The scale of an Spinner component is the set of * allowed values for the <code>value</code> property. * The allowed values are the sum of the minimum with * integer multiples of the <code>snapInterval</code> property * which are less than or equal to the <code>maximum</code>value. * For example:</p> * * <ul> * <li><code>minimum</code> = -1</li> * <li><code>maximum</code> = 10</li> * <li><code>snapInterval</code> = 3</li> * </ul> * * Therefore the scale is {-1,2,5,8,10}. * * @see spark.components.NumericStepper * @see spark.skins.spark.SpinnerSkin */ public class Spinner extends Range implements IFocusManagerComponent { include "../core/Version.as"; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. */ public function Spinner():void; //-------------------------------------------------------------------------- // // SkinParts // //-------------------------------------------------------------------------- //---------------------------------- // decrementButton //---------------------------------- [SkinPart(required="false")] /** * A skin part that defines the button that, * when pressed, decrements the <code>value</code> property * by <code>stepSize</code>. */ public var decrementButton:Button; //---------------------------------- // incrementButton //---------------------------------- [SkinPart(required="false")] /** * A skin part that defines the button that, * when pressed, increments the <code>value</code> property * by <code>stepSize</code>. */ public var incrementButton:Button; //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // valueWrap //---------------------------------- /** * Determines the behavior of the control for a step when the current * <code>value</code> is either the <code>maximum</code> * or <code>minimum</code> value. * If <code>allowValueWrap</code> is <code>true</code>, then the * <code>value</code> property wraps from the <code>maximum</code> * to the <code>minimum</code> value, or from * the <code>minimum</code> to the <code>maximum</code> value. * * @default false */ public function get allowValueWrap():Boolean; public function set allowValueWrap(value:Boolean):void; //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- /** * Handle a click on the incrementButton. This should * increment <code>value</code> by <code>stepSize</code>. */ protected function incrementButton_buttonDownHandler(event:Event):void; /** * Handle a click on the decrementButton. This should * decrement <code>value</code> by <code>stepSize</code>. */ protected function decrementButton_buttonDownHandler(event:Event):void; /** * Handles the <code>mouseWheel</code> event * when the component is in focus. * The spinner is moved by the amount of the mouse event delta * multiplied by the <code>stepSize</code>. */ protected function system_mouseWheelHandler(event:MouseEvent):void; } } B Featuresnone so far Additional Implementation Detailsnone Prototype WorkPrototype of Spinner has shown that it can be a very lightweight base class for NumericStepper and other custom controls. Compiler Worknone Web Tier Compiler Impactnone Flex Feature DependenciesSpinner depends on Range as its base class. Backwards CompatibilitySyntax changesNone - New Class AccessibilityProvides accessibility for NumericStepper and similar controls. Issues and Recommendations
|
|
| You must be logged in to comment. |
|---|

Comments (1)
Aug 13, 2008
Greg Yantz says:
In the example provided at the top of the page, shouldn't the resulting scale be...In the example provided at the top of the page, shouldn't the resulting scale be {-1, 2, 5, 8, 10}? In the example, the first step is 4, not 3.