[1227] | 1 | package gov.va.med.edp.widget
|
---|
| 2 | {
|
---|
| 3 | import mx.events.FlexMouseEvent;
|
---|
| 4 | import mx.events.FlexEvent;
|
---|
| 5 | import mx.controls.NumericStepper;
|
---|
| 6 | import mx.core.mx_internal;
|
---|
| 7 | import mx.core.UIComponent;
|
---|
| 8 | import mx.managers.IFocusManagerComponent;
|
---|
| 9 |
|
---|
| 10 | import flash.events.FocusEvent;
|
---|
| 11 | import flash.events.Event;
|
---|
| 12 | import flash.accessibility.AccessibilityProperties;
|
---|
| 13 | import flash.events.KeyboardEvent;
|
---|
| 14 | import flash.events.MouseEvent;
|
---|
| 15 | import flash.ui.Keyboard;
|
---|
| 16 |
|
---|
| 17 | use namespace mx_internal;
|
---|
| 18 |
|
---|
| 19 | [AccessibilityClass(implementation="gov.va.med.edp.widget.accessibility.NumericStepperAccImpl")]
|
---|
| 20 |
|
---|
| 21 | [Event(name="dataChange", type="mx.events.FlexEvent")]
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * Dispatched when the user presses the Enter key.
|
---|
| 25 | *
|
---|
| 26 | * @eventType mx.events.FlexEvent.ENTER
|
---|
| 27 | */
|
---|
| 28 | [Event(name="enter", type="mx.events.FlexEvent")]
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | [DataBindingInfo("editEvents", ""focusIn;focusOut"stepSizeMouseClickChanged"")]
|
---|
| 32 |
|
---|
| 33 | [DefaultBindingProperty(source="text", destination="text")]
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | public class AccessibleNumericStepper extends NumericStepper //implements IFocusManagerComponent
|
---|
| 37 | {
|
---|
| 38 | /**
|
---|
| 39 | * @private
|
---|
| 40 | * Placeholder for mixin by ComboBoxAccImpl.
|
---|
| 41 | */
|
---|
| 42 | mx_internal static var createAccessibilityImplementation:Function;
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * @private
|
---|
| 46 | */
|
---|
| 47 | private var iNum:int;
|
---|
| 48 |
|
---|
| 49 | /**
|
---|
| 50 | * Constructor
|
---|
| 51 | */
|
---|
| 52 | public function AccessibleNumericStepper()
|
---|
| 53 | {
|
---|
| 54 | super();
|
---|
| 55 | tabChildren = true;
|
---|
| 56 | tabEnabled = true;
|
---|
| 57 | this.addEventListener(KeyboardEvent.KEY_UP,keyButtonHandler);
|
---|
| 58 | this.addEventListener(MouseEvent.CLICK,buttonClickHandler);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | /**
|
---|
| 62 | * @protected
|
---|
| 63 | * Activates accessibility
|
---|
| 64 | */
|
---|
| 65 | override protected function initializeAccessibility():void
|
---|
| 66 | {
|
---|
| 67 | if (AccessibleNumericStepper.createAccessibilityImplementation != null)
|
---|
| 68 | AccessibleNumericStepper.createAccessibilityImplementation(this);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | * @protected
|
---|
| 73 | * Method that handles focus in events
|
---|
| 74 | */
|
---|
| 75 | override protected function focusInHandler(event:FocusEvent):void
|
---|
| 76 | {
|
---|
| 77 | super.focusInHandler(event);
|
---|
| 78 | drawFocus(true);
|
---|
| 79 | dispatchEvent(new Event("numericStepperFocused"));
|
---|
| 80 | //event.stopPropagation();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | /**
|
---|
| 84 | * @private
|
---|
| 85 | * Method that handles mouse button click events
|
---|
| 86 | */
|
---|
| 87 | private function buttonClickHandler(event:MouseEvent):void
|
---|
| 88 | {
|
---|
| 89 | dispatchEvent(new Event("stepSizeMouseClickChanged"));
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * @private
|
---|
| 94 | * Method that handles key button down events
|
---|
| 95 | */
|
---|
| 96 | private function keyButtonHandler(event:KeyboardEvent):void
|
---|
| 97 | {
|
---|
| 98 | switch (event.keyCode)
|
---|
| 99 | {
|
---|
| 100 | case Keyboard.ENTER:
|
---|
| 101 | {
|
---|
| 102 | dispatchEvent(new FlexEvent(FlexEvent.ENTER));
|
---|
| 103 | break;
|
---|
| 104 | }
|
---|
| 105 | case Keyboard.DOWN:
|
---|
| 106 | {
|
---|
| 107 | dispatchEvent(new FlexEvent(FlexEvent.BUTTON_DOWN));
|
---|
| 108 | break;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | dispatchEvent(new Event("stepSizeChanged"));
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | * @private
|
---|
| 118 | */
|
---|
| 119 | override public function get tabIndex():int
|
---|
| 120 | {
|
---|
| 121 | return iNum;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | * @private
|
---|
| 126 | */
|
---|
| 127 | override public function set tabIndex(value:int):void
|
---|
| 128 | {
|
---|
| 129 | iNum = value;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | }
|
---|
| 134 | }
|
---|