source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/widget/AccessibleNumericStepper.as@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 3.3 KB
Line 
1package gov.va.med.edp.widget
2{
3import mx.events.FlexMouseEvent;
4import mx.events.FlexEvent;
5import mx.controls.NumericStepper;
6import mx.core.mx_internal;
7import mx.core.UIComponent;
8import mx.managers.IFocusManagerComponent;
9
10import flash.events.FocusEvent;
11import flash.events.Event;
12import flash.accessibility.AccessibilityProperties;
13import flash.events.KeyboardEvent;
14import flash.events.MouseEvent;
15import flash.ui.Keyboard;
16
17use 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&quot")]
32
33[DefaultBindingProperty(source="text", destination="text")]
34
35
36public 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}
Note: See TracBrowser for help on using the repository browser.