简体   繁体   中英

How select an item from drop-down of com-box with Enter Key in Flex?

I want to select item from a combo-box with enter key, is that any built in combo-box event not key-down event.

Thanks

There are various events you can use to catch this.

For instance all Spark Lists (that includes DropDownList and ComboBox) dispatch an IndexChangeEvent.CHANGE whenever, well, the selected index changes. This event carries information on the selected index ( newIndex ) and the one that was just deselected ( oldIndex ).

A more generic event is also dispatched, one that all "input" components dispatch when their value changes: FlexEvent.VALUE_COMMIT . This doesn't carry any other information.

Both these events are dispatched regardless of whether an item was selected through mouse click or through keyboard selection.

Perhaps you want to catch just the event that an item was selected through the keyboard. In this case you can listen for either FlexEvent.ENTER , which is only dispatched when the Enter button is pressed; or for the more generic KeyboardEvent.KEY_UP , in which case you'll have to manually find out whether the pressed key is an enter key or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM