PDA

View Full Version : Combobox events specialkey / select



fmeric
3 Jul 2014, 7:08 AM
Hello,

I have a combobox, on which i set the following listeners :
- specialkey
- select
I'm actually trying to perform a specific action when i write some value in my combobox and press ENTER, and another specific action when i choose one of the items listed in the boundlist.

I've put a testcase here : https://fiddle.sencha.com/#fiddle/7bv

When i write something in the combo and press ENTER, i get correctly the event specialkey.
When i write something in the combo to filter the boundlist and clic on an item, i get correctly the event select.
But, when i navigate through the boundlist with arrow keys, and press enter on an item to select it, i got both events fired.

Is there a way to have only the select event fired when i select an item with arrow keys and enter key ?

fmeric
3 Jul 2014, 1:45 PM
Ok, so i found a dirty workaround i can live with temporarely, thanks to those links :
- http://www.sencha.com/forum/showthread.php?271118
- http://stackoverflow.com/questions/17566718/call-events-delayed-with-all-its-arguments

Quick explanation : i delay my specialkey listener by few ms so it arrives after the select event. I make sure to suspend events before calling the delayed handler and resume them at end of the handler. In my specialkey handler, i check if selection is empty to determine if i have pressed enter in the field or on an item. I still have to keep my select handler to catch select events by clic.

Applied to my testcase, it gives this result : https://fiddle.sencha.com/#fiddle/7ck