我有一台ViewStack,里面有一堆NavigatorContainers。每个NavigatorContainer包含应用程序的不同类别的设置。
我希望能够显示弹出窗口,提示用户是否尝试离开当前的NavigatorContainer,而不保存对容器设置所做的更改。
理想的情况是类似于List组件中的“changing”事件,这样您就可以取消或推迟该事件。在ViewStack中的change事件上调用preventDefault()不会阻止索引更改的发生。
有没有办法用最少的跳圈来做到这一点呢?
谢谢
发布于 2012-01-09 21:53:33
这取决于是什么改变了您的视图堆栈。例如,如果你使用ButtonBar作为视图转换器,那么你可以很容易地这样写:
protected function btnBar_changingHandler(event:IndexChangeEvent):void
{
event.preventDefault();
//enter code here
}和
<s:VGroup width="100%" height="100%" horizontalAlign="center">
<s:ButtonBar id="btnBar" dataProvider="{viewStack}" requireSelection="true" changing="btnBar_changingHandler(event)">
<s:layout>
<s:ButtonBarHorizontalLayout gap="2" />
</s:layout>
</s:ButtonBar>
<mx:ViewStack id="viewStack" width="100%" height="100%">
<s:NavigatorContent width="100%" height="100%" label="First View">
<comp:FirstView/>
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" label="Second View">
<comp:SecondView/>
</s:NavigatorContent>
</mx:ViewStack>
</s:VGroup>发布于 2012-01-07 10:50:22
如果索引更改时没有发生可怕的事情,为什么不保留当前的索引,然后在更改事件中弹出它们并给出警报?
https://stackoverflow.com/questions/8765918
复制相似问题