source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/widget/AccessibleLabel.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: 2.9 KB
RevLine 
[1227]1package gov.va.med.edp.widget
2{
3 import flash.events.Event;
4 import flash.events.FocusEvent;
5
6 import gov.va.med.edp.util.AccessibilityTools;
7 import gov.va.med.edp.widget.accessibility.AccessibleLabelAccImpl;
8 import gov.va.med.edp.widget.accessibility.IAccessibleComponent;
9
10 import mx.controls.Label;
11 import mx.managers.IFocusManagerComponent;
12
13 /**
14 * This class extends the mx Label class in order to make them focusable.
15 * For a user with a screen reader, if the image is critical to the application
16 * you will need to have some way to communicate a summary of the image's information
17 * to a screen reader.
18 *
19 * You can check if a screen reader is being used to make this component
20 * behave like the standard label component so a user that does not need
21 * accessibility features will not see the tooltips or be able to tab
22 * to label components.
23 */
24 public class AccessibleLabel extends Label
25 implements IFocusManagerComponent, IAccessibleComponent
26 {
27 /**
28 * @private
29 */
30 private var _accessibleText:String = "";
31
32 /**
33 * Constructor
34 */
35 public function AccessibleLabel()
36 {
37 super();
38 }
39
40 /**
41 * @public
42 * Method to set accessible text.
43 */
44 public function set accessibleText(s:String):void
45 {
46 _accessibleText = s;
47 dispatchEvent(new Event("accessibleTextChanged"));
48 }
49
50 /**
51 * @public
52 * Method to get accessible text.
53 */
54 public function get accessibleText():String
55 {
56 return _accessibleText;
57 }
58
59 /**
60 * The properties are set on creation complete.
61 * accessibilityProperties will be guaranteed
62 * to be accurate at this point
63 * and the accessibility changes
64 * can be made accordingly.
65 **/
66 override protected function commitProperties():void
67 {
68
69 if ((accessibilityProperties != null)
70 && (AccessibilityTools.isAccessibilityActive()))
71 {
72 focusEnabled = true;
73 tabEnabled = true;
74 accessibilityImplementation = new AccessibleLabelAccImpl(this);
75 setStyle("focusThickness", 2);
76
77 }
78 else
79 {
80 focusEnabled = false;
81 tabEnabled = false;
82 removeEventListener(FocusEvent.FOCUS_IN, focusInHandler);
83 removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
84 }
85 }
86
87 /**
88 * @protected
89 * Method that handles focus in events
90 */
91 override protected function focusInHandler(event:FocusEvent):void
92 {
93 _accessibleText = (_accessibleText == "" ? text : _accessibleText);
94
95 // revised by jtorreno 07/29/2008
96 // fix for null error exception if component is null
97 if ((focusManager != null) && (focusManager.getFocus() != null))
98 {
99 drawFocus(true);
100 }
101
102 event.stopPropagation();
103 }
104
105
106 }
107}
108
Note: See TracBrowser for help on using the repository browser.