问题
I'm trying to add accessibility to my application. I still can't figure out exactly how accessibility works in spark components.
I'm on window's platform with the narrator function enabled.
All I want to do is to name the three fields with a different name for accessibility so the user knows what to do.
I tried to just use declaration to define the accessibility properties but it seems like it will always only speak out one name of the button. Thus, I took another approach and tried to create the accessibility properties when it does the creation complete. It seems like the narrator is sometimes picking up the correct name of the accessibility in the beginning, then very soon, when I goto the button, it'll replace all the name and call it "search button". Any idea why?!?! I'm very puzzled. Any help will be appreciated.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:accessbility="flash.accessibility.*" initialize="onInit()" creationComplete="onComplete()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.modernista.swffocus.SWFFocus;
private function onComplete():void {
var ap1:AccessibilityProperties = new AccessibilityProperties();
ap1.name = "search";
searchInput.accessibilityProperties = ap1;
var ap2:AccessibilityProperties = new AccessibilityProperties();
ap2.name = "name input";
nameInput.accessibilityProperties = ap2;
var sb:AccessibilityProperties = new AccessibilityProperties();
sb.name = "search button";
searchSubmit.accessibilityProperties = sb;
Accessibility.updateProperties();
}
// this helps Firefox capture and release keyboard focus
private function onInit():void {
SWFFocus.init(systemManager.stage as Stage);
}
]]>
</fx:Script>
<mx:Form defaultButton="{searchSubmit}">
<mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" >
<mx:TextInput id="searchInput" width="540">
</mx:TextInput>
<mx:TextInput id="nameInput" width="540">
</mx:TextInput>
<mx:Button id="searchSubmit" label="search" />
</mx:HBox>
</mx:Form>
</s:WindowedApplication>
回答1:
All I want to do is to name the three fields with a different name for accessibility so the user knows what to do. I tried to just use declaration to define the accessibility properties but it seems like it will always only speak out one name of the button.
MS Narrator is one of those tools that you only use if you have no other options. Think of that creepy old gas station when you are in the middle of no where. I would test the application using NVDA, a free screen reader that is as good as JAWS, and more acceptable to test with (NVDA v. MS Narrator).
Thus, I took another approach and tried to create the accessibility properties when it does the creation complete. It seems like the narrator is sometimes picking up the correct name of the accessibility in the beginning, then very soon, when I goto the button, it'll replace all the name and call it "search button"
I would attribute this more to the wonkiness of Narrator.
It also looks like you didn't include the Accessibility Library, but I am not a Flex dev, so I don't know if they are needed, like in Flash.
Your Code
var sb:AccessibilityProperties = new AccessibilityProperties();
sb.name = "search button";
I would take out button here. Most assistive tech adds on element types to things, so this button would be announced as Search button button.
Further reading:
- http://www.sitepoint.com/accessibility-in-flex-apps/
- http://www.adobe.com/accessibility/products/flex/best_practices.html
来源:https://stackoverflow.com/questions/16729376/desktop-air-application-accessibility