-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I've gone through all the ZK documentation that I could find on listening for keyboard events, such as ENTER. But, all those solutions suppose an MVC approach with a Composer bound to the view. So, I'm a bit lost as to how to implement a listener in the MVVM architecture so that, if the user hits ENTER in any form textbox, it will behave as if the the button had been clicked and thereby execute the associated button's onClick @Command.
Thanks for any help.
Ron
Capture Enter key in all controls in hlayout and send 'command' command:
<hlayout forward="onOK=btn.onClick"> <textbox/> <combobox/> <checkbox/> </hlayout> <button id="btn" label="btn" onClick="@command('command')"/>
Just some ideas:
ENTER usually raises onOK, you could bind your command to it
onOK="@command('cmd')"
forward="onOk=onChange"
Please post your final solution. I'm interested in that, too.
Thanks. Yes, I had found that the onOK event can be used on textbox, but it was my understanding (pre MVVM), one could set up a keylistener on the entire form. It looks like we now (under MVVM) have to have an onOK event coded on every form input field, which seems a bit ridiculous just to capture the ENTER key. Plus, I don't know why the ZK team thought they would break convention of using keyup and keydown listeners and go with onOK, which implies someone has click the OK button on a modal window. It's not very intuitive.
I'll post back if I find a better solution.
Asked: 2012-04-19 22:33:15 +0800
Seen: 427 times
Last updated: Oct 25 '12