Flex Combobox preChange事件 [英] Flex Combobox preChange event

查看:171
本文介绍了Flex Combobox preChange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我需要在更改combobox值之前向用户弹出警报。
此功能允许用户在未保存修改的情况下保持当前状态。

I have a project in which i need to pop up an alert to the user before a combobox value is changed. This feature is to allow the user to stay in current state if modifications were not saved. Meaning that the user will be able to cancel the change.

我有子类ComboBox并试图挂钩ComboBox.dropdown的ITEM_CLICK,但此事件在值被触发后改变。此外,我尝试MOUSE_CLICK和MOUSE_DOWN但没有成功。

I have sub classed ComboBox and tried to hook on ITEM_CLICK of ComboBox.dropdown but this event is triggered after the value is changed. Also, I've tried MOUSE_CLICK ans MOUSE_DOWN but without success.

在我的代码中,我已经添加了一个preChange事件到我的CustomComboBox。此事件应在更改之前触发。另外,我引入了一个名为commitChange的方法,将被手动调用以实际提交更改。

In my code, I have added a "preChange" event to my CustomComboBox. This event should be triggered before a change is made. Also, I've introduced a method called commitChange that will be called manually to actually commit the change.

如何获得所需的结果?

推荐答案

最简单的方法是在ComboBox的Event.CHANGE中添加两个监听器,然后设置要触发的处理程序的优先级先于更改为负值。例如:

The easiest way to do it is to add two listeners to Event.CHANGE on the ComboBox, then set the priority of the handler you want to fire prior to the change as a negative value. For example:

myComboBox.addEventListener(Event.CHANGE, preChange, false, -100);
myComboBox.addEventListener(Event.CHANGE, postChange, false, 100);

事件分派的顺序:


  1. preChange(event:Event)

  2. 继承的更改事件(默认优先级为0)

  3. postChange :Event)

这篇关于Flex Combobox preChange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆