我正在尝试为我的应用程序添加可访问性。我仍然无法弄清楚可访问性在 spark 组件中是如何工作的。
我在window的平台上启用了旁白功能。我想要做的就是用不同的名称命名这三个字段以方便访问,以便用户知道该做什么。我试图只使用声明来定义可访问性属性,但似乎它总是只会说出按钮的一个名称。因此,我采用了另一种方法并尝试在创建完成后创建可访问性属性。似乎叙述者有时会在开始时选择正确的可访问性名称,然后很快,当我转到按钮时,它会替换所有名称并将其称为“搜索按钮”。知道为什么吗?!?!我很困惑。任何帮助将不胜感激。
<?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>