1 | package gov.va.med.edp.widget.accessibility
|
---|
2 | {
|
---|
3 | import gov.va.med.edp.widget.LinkButtonTab;
|
---|
4 | import gov.va.med.edp.widget.LinkButtonTabBar;
|
---|
5 |
|
---|
6 | import mx.accessibility.TabBarAccImpl;
|
---|
7 | import mx.core.UIComponent;
|
---|
8 | import mx.core.mx_internal;
|
---|
9 |
|
---|
10 | use namespace mx_internal;
|
---|
11 |
|
---|
12 | public class LinkButtonTabBarAccImpl extends TabBarAccImpl
|
---|
13 | {
|
---|
14 | private static const MAX_NUM:uint = 100000;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * @private
|
---|
18 | * Static variable triggering the hookAccessibility() method.
|
---|
19 | * This is used for initializing LinkButtonTabBarAccImpl class to hook its
|
---|
20 | * createAccessibilityImplementation() method to LinkButtonTabBar class
|
---|
21 | * before it gets called from UIComponent.
|
---|
22 | */
|
---|
23 | private static var accessibilityHooked:Boolean = hookAccessibility();
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * @private
|
---|
27 | * Static method for swapping the createAccessibilityImplementation()
|
---|
28 | * method of LinkButtonTabBar with LinkButtonTabBarAccImpl class.
|
---|
29 | */
|
---|
30 | private static function hookAccessibility():Boolean
|
---|
31 | {
|
---|
32 | LinkButtonTabBar.createAccessibilityImplementation =
|
---|
33 | createAccessibilityImplementation;
|
---|
34 |
|
---|
35 | return true;
|
---|
36 | }
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @private
|
---|
40 | * Method for creating the Accessibility class.
|
---|
41 | * This method is called from UIComponent.
|
---|
42 | * @review
|
---|
43 | */
|
---|
44 | mx_internal static function createAccessibilityImplementation(
|
---|
45 | component:UIComponent):void
|
---|
46 | {
|
---|
47 | component.accessibilityImplementation =
|
---|
48 | new LinkButtonTabBarAccImpl(component);
|
---|
49 | }
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Method call for enabling accessibility for a component.
|
---|
53 | * This method is required for the compiler to activate
|
---|
54 | * the accessibility classes for a component.
|
---|
55 | */
|
---|
56 | public static function enableAccessibility():void
|
---|
57 | {
|
---|
58 | }
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Constructor.
|
---|
62 | *
|
---|
63 | * @param master The UIComponent instance that this AccImpl instance
|
---|
64 | * is making accessible.
|
---|
65 | */
|
---|
66 | public function LinkButtonTabBarAccImpl(master:UIComponent)
|
---|
67 | {
|
---|
68 | super(master);
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * @private
|
---|
73 | * method for returning the name of the Tab
|
---|
74 | * which is spoken out by the screen reader.
|
---|
75 | *
|
---|
76 | * @param childID:uint
|
---|
77 | *
|
---|
78 | * @return Name:String
|
---|
79 | */
|
---|
80 | override protected function getName(childID:uint):String
|
---|
81 | {
|
---|
82 | if (childID == 0)
|
---|
83 | return "View Selector Panel";
|
---|
84 |
|
---|
85 | var name:String;
|
---|
86 |
|
---|
87 | var tabBar:LinkButtonTabBar = LinkButtonTabBar(master);
|
---|
88 | // Assuming childID is always ItemID + 1
|
---|
89 | // because getChildIDArray is not always invoked.
|
---|
90 | var index:int = childID < MAX_NUM ?
|
---|
91 | childID - 1 :
|
---|
92 | childID - MAX_NUM - 1;
|
---|
93 | //With new version of JAWS, when we add a new child, we get nonsense number
|
---|
94 | //not caught above. In this case, return last tab.
|
---|
95 | if (index > tabBar.numChildren || index < 0)
|
---|
96 | index = tabBar.numChildren -1;
|
---|
97 | var item:LinkButtonTab = LinkButtonTab(tabBar.getChildAt(index));
|
---|
98 |
|
---|
99 | name = item.label;
|
---|
100 |
|
---|
101 | if (index == tabBar.selectedIndex)
|
---|
102 | name += " Tab, Active";
|
---|
103 | else
|
---|
104 | name += " Tab";
|
---|
105 |
|
---|
106 | return name;
|
---|
107 | }
|
---|
108 |
|
---|
109 | }
|
---|
110 | }
|
---|