views:

14

answers:

1

I have a handler for itemSelectEvent that gets called when an option is selected from the drop down. According to YUI documentation, this is fired when an item is selected via mouse click, ENTER key, or TAB key. Inside my handler, how can I find out which of these three options fired my handler? The handler takes two parameters: 1) the type, which is "itemSelect", and the args, which have the AutoComplete instance and some other stuff. I see the AutoComplete instance has a _nKeyCode, but its value is always 40 and it does not seem to change if I select an option using TAB or ENTER. Any help would be appreciated. Thanks!

A: 

I took a peek at the source autocomplete code, just because I was curious. It doesn't look like the code is very discerning about which option fired the handler. Also from previous experience I've had little success with keyCodes -- too complicated and browser specific for me to attack.

However the itemSelect code is catching the keyDown events. So you could potentially create new separate handlers for keyUp events, which do nothing unless they come immediately after your itemSelect event. Tricky, and hacky, but the best I could think of.

mjhm