tags:

views:

209

answers:

1

Hi all,

I have a dojo.dnd.Source container with multiple dnd items. I'd like to give the user the option to select one of the dnd items in the source and then use their backwards/forwards keys to navigate to other items in the source. I've tried setting onkeyup/onkeydown handlers on the dnd items, but they don't seem to fire. I've also tried setting key handlers on the dnd source container, but no luck there either.

Any ideas on whether this is possible - if so, on what dom node should I attach my keyup/keydown listeners?

Thanks

Sean

PS - using dojo 1.3 in an Adobe AIR application.

A: 

In general key events are not position-specific like mouse events, and they target a focused node, like a radio button, or a text box. I suspect you don't have form nodes there. You can always try to emulate it yourself, but Dojo DnD doesn't support it out of the box.

Eugene Lazutkin
Thanks Eugene,@nicrizzo prompted me to attach a keyup handler to dojo.doc and take it from there. I tried this and looked into generating the event to pass into onMouseDown in Selector.js, but that proved to be a little difficult. I ended up looking at the selectAll function function in Selector.js and was able to come up with some logic where I could pass the id of the node I wanted to mark as selected into _addItemClass. That seems to work fine. What would you think of an API in Selector.js which accepts a domNode or id which you want to mark as selected?
That would be fine, but it should be implemented as addon, so whoever needs it, should just "dojo.require" it. Sign a CLA, open an enhancement ticket, and attach a patch.
Eugene Lazutkin
Hey Eugene,Gave what you suggested a try - if you think the API is useful and code is solid, I'll go ahead and fill in a CLA and open an enhancement ticket.CheersSean
Looks good. Go ahead with CLA, but don't forget to add relevant tests.
Eugene Lazutkin
Hey Eugene - added tests and full source code to http://github.com/seanoshea/dojox-dnd. Will get the CLA in tomorrow. Have a few ideas about allowing users use a bounding box to select dnd items - might add it to the git repo in a few days. Sean
Let me know when CLA is in, and the name you used in CLA.
Eugene Lazutkin
Just sent in the CLA Eugene. The name I used was Sean O' Shea. Let me know what the next steps are. Sean.