[1227] | 1 | package gov.va.med.edp.widget.accessibility
|
---|
| 2 | {
|
---|
| 3 | import flash.accessibility.Accessibility;
|
---|
| 4 | import flash.events.Event;
|
---|
| 5 |
|
---|
| 6 | import mx.accessibility.AccImpl;
|
---|
| 7 | import mx.core.UIComponent;
|
---|
| 8 | import mx.core.mx_internal;
|
---|
| 9 |
|
---|
| 10 | import gov.va.med.edp.widget.AccessibleNumericStepper;
|
---|
| 11 |
|
---|
| 12 | use namespace mx_internal;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * The NumericStepperAccImpl class is the accessibility class
|
---|
| 16 | * the numericstepper component.
|
---|
| 17 | *
|
---|
| 18 | * @tiptext This is the NumericStepperAccImpl Accessibility Class.
|
---|
| 19 | * @created by jtorreno 6.2.2008
|
---|
| 20 | */
|
---|
| 21 | public class NumericStepperAccImpl extends AccImpl
|
---|
| 22 | {
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * @private
|
---|
| 26 | * Default role for numericstepper
|
---|
| 27 | */
|
---|
| 28 | private const ROLE_SYSTEM_TEXT:uint = 0x0000002A;
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * @private
|
---|
| 32 | * Default state for all the components.
|
---|
| 33 | */
|
---|
| 34 | private static const STATE_SYSTEM_NORMAL:uint = 0x00000000;
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * @private
|
---|
| 38 | */
|
---|
| 39 | private static const STATE_SYSTEM_FOCUSABLE:uint = 0x00100000;
|
---|
| 40 |
|
---|
| 41 | /**
|
---|
| 42 | * @private
|
---|
| 43 | */
|
---|
| 44 | private static const STATE_SYSTEM_FOCUSED:uint = 0x00000004;
|
---|
| 45 |
|
---|
| 46 | /**
|
---|
| 47 | * @private
|
---|
| 48 | **/
|
---|
| 49 | private static const EVENT_OBJECT_FOCUS:uint = 0x8005;
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
| 52 | * @private
|
---|
| 53 | */
|
---|
| 54 | private static const EVENT_OBJECT_VALUECHANGE:uint = 0x0000800e;
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * @private
|
---|
| 58 | * Accessibility hookup
|
---|
| 59 | */
|
---|
| 60 | private static var accessibilityHooked:Boolean = hookAccessibility();
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | * Constructor
|
---|
| 65 | */
|
---|
| 66 | public function NumericStepperAccImpl(master:UIComponent)
|
---|
| 67 | {
|
---|
| 68 | super(master);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | * @private
|
---|
| 73 | * Method for creating the Accessibility class.
|
---|
| 74 | * This method is called from UIComponent.
|
---|
| 75 | * @review
|
---|
| 76 | */
|
---|
| 77 | mx_internal static function createAccessibilityImplementation(
|
---|
| 78 | component:UIComponent):void
|
---|
| 79 | {
|
---|
| 80 | component.accessibilityImplementation =
|
---|
| 81 | new NumericStepperAccImpl(component);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | * @private
|
---|
| 86 | * Static method for swapping the createAccessibilityImplementation()
|
---|
| 87 | * method of AccessibleNumericStepper with the NumericStepperAccImpl class.
|
---|
| 88 | */
|
---|
| 89 | private static function hookAccessibility():Boolean
|
---|
| 90 | {
|
---|
| 91 | AccessibleNumericStepper.createAccessibilityImplementation =
|
---|
| 92 | createAccessibilityImplementation;
|
---|
| 93 | return true;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | /**
|
---|
| 97 | * Method call for enabling accessibility for a component.
|
---|
| 98 | * this method is required for the compiler to activate
|
---|
| 99 | * the accessibility classes for a component.
|
---|
| 100 | */
|
---|
| 101 | public static function enableAccessibility():void
|
---|
| 102 | {
|
---|
| 103 |
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | /**
|
---|
| 107 | * @private
|
---|
| 108 | * Method for returning the name of the NumericStepper
|
---|
| 109 | *
|
---|
| 110 | * @param childID uint
|
---|
| 111 | *
|
---|
| 112 | * @return Name String
|
---|
| 113 | * @review
|
---|
| 114 | */
|
---|
| 115 | override protected function getName(childID:uint):String
|
---|
| 116 | {
|
---|
| 117 | var name:String = "";
|
---|
| 118 |
|
---|
| 119 | name = AccessibleNumericStepper(master).name;
|
---|
| 120 |
|
---|
| 121 | return name;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | * @private
|
---|
| 126 | * Method for returning the value of the NumericStepper
|
---|
| 127 | *
|
---|
| 128 | * @param childID uint
|
---|
| 129 | *
|
---|
| 130 | * @return Value String
|
---|
| 131 | * @review
|
---|
| 132 | */
|
---|
| 133 | override public function get_accValue(childID:uint):String
|
---|
| 134 | {
|
---|
| 135 | var accValue:String="";
|
---|
| 136 |
|
---|
| 137 | accValue = AccessibleNumericStepper(master).value.toString();
|
---|
| 138 |
|
---|
| 139 | return accValue;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | /**
|
---|
| 143 | * @private
|
---|
| 144 | * IAccessible method for returning the state of the NumericStepper
|
---|
| 145 | *
|
---|
| 146 | * @param childID uint
|
---|
| 147 | *
|
---|
| 148 | * @return State uint
|
---|
| 149 | */
|
---|
| 150 | override public function get_accState(childID:uint):uint
|
---|
| 151 | {
|
---|
| 152 | var accState:uint = STATE_SYSTEM_NORMAL;
|
---|
| 153 |
|
---|
| 154 | if (AccessibleNumericStepper(master).getFocus())
|
---|
| 155 | {
|
---|
| 156 | accState |= STATE_SYSTEM_FOCUSED;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | return accState;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /**
|
---|
| 163 | * @private
|
---|
| 164 | * Gets the role for the component.
|
---|
| 165 | *
|
---|
| 166 | * @param childID uint.
|
---|
| 167 | */
|
---|
| 168 | override public function get_accRole(childID:uint):uint
|
---|
| 169 | {
|
---|
| 170 | return ROLE_SYSTEM_TEXT;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | /**
|
---|
| 174 | * @private
|
---|
| 175 | * Array of events that we should listen for from the master component.
|
---|
| 176 | */
|
---|
| 177 | override protected function get eventsToHandle():Array
|
---|
| 178 | {
|
---|
| 179 | return super.eventsToHandle.concat(["numericStepperFocused","stepSizeChanged","stepSizeMouseClickChanged"]);
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
| 183 | * @private
|
---|
| 184 | * Override the generic event handler.
|
---|
| 185 | * All AccImpl must implement this to listen for events
|
---|
| 186 | * from its master component.
|
---|
| 187 | */
|
---|
| 188 | override protected function eventHandler(event:Event):void
|
---|
| 189 | {
|
---|
| 190 | //trace("&&&&&&&&&& Event Type: " + event.type);
|
---|
| 191 | switch (event.type)
|
---|
| 192 | {
|
---|
| 193 | /* tell JAWS to update and reread the information */
|
---|
| 194 | case "stepSizeChanged":
|
---|
| 195 | {
|
---|
| 196 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_FOCUS);
|
---|
| 197 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_VALUECHANGE);
|
---|
| 198 | Accessibility.updateProperties();
|
---|
| 199 | break;
|
---|
| 200 | }
|
---|
| 201 | case "stepSizeMouseClickChanged":
|
---|
| 202 | {
|
---|
| 203 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_FOCUS);
|
---|
| 204 | //Accessibility.sendEvent(master, 0, EVENT_OBJECT_STATECHANGE);
|
---|
| 205 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_VALUECHANGE);
|
---|
| 206 | Accessibility.updateProperties();
|
---|
| 207 | break;
|
---|
| 208 | }
|
---|
| 209 | case "numericStepperFocused":
|
---|
| 210 | {
|
---|
| 211 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_FOCUS);
|
---|
| 212 | Accessibility.sendEvent(master, 0, EVENT_OBJECT_VALUECHANGE);
|
---|
| 213 | Accessibility.updateProperties();
|
---|
| 214 | break;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | }
|
---|
| 221 | }
|
---|