-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello everyone, i need for my app that the onOK event is triggered when the user stops pressing the Intro key. not when they press. It's a Form-like APP, each time you press intro on a field, the focus jumps to the next field to fill. The app goes great when they go pressing intro on each field, but the problem starts when they keep the button pressed after filling one field, it will start jumping fast to each field and all the validations will popup onscreen.
Any chance on interrupting the onOK event to wait till te user release the key, or replace it for the keyup event?
Thanks in advance and sorry about my poor eng.
To me this sounds like a training issue of the users. I think nowadays it's a well established standard to use the [TAB]-key to switch from one to the next field. And on top of that I don't understand who would press the ENTER key longer on purpose, just to jump between fields.
BTW: Client side constraints will also fire when pressing TAB to jump between input fields. So if that's the case throttling the onOK event will have no effect, still the focus will change triggering a client side input field validation, or if the server side listens to onChange also the server side constraint validation will trigger, unrelated to the existence of an onOK event.
I am aware of the fact that back in the day of old terminal (emulated) client/server software the ENTER-key was used to jump from field to field. Based on your description I am not yet clear which problem you really want to solve, preventing the onOK event or preventing the constraint evaluation?
Here a running example that demonstrates the described above. You'll see that pressing TAB will not trigger the onOK event but still switch to the next textbox triggering the "no empty" constraint to display an error message. So onOK is not the cause here, and trying to avoid it will not fix the problem
Can you change the example to match your requirements, then we try to give a suitable advice.
Hello Zayuke!
Uhmmm client side programming scenario... This might give you some inspiration about the key-up management:
<zk>
<script type="text/javascript" defer="true"><![CDATA[
var myInputs = $('.checkThis');
for(i = 0; i < myInputs.length; i++) {
myInputs[i].onkeyup = function(e) {
var code = e.keyCode || e.which;
if (code == '9') {
alert("Tab key up!")
}
};
}
]]></script>
<window id="win" title="new page title" border="normal">
<vlayout>
<textbox sclass="checkThis" />
<textbox sclass="checkThis" />
<textbox sclass="checkThis" />
<textbox sclass="checkThis" />
</vlayout>
</window>
</zk>
Then you will need to decide what to do with the e.target (your textbox).
As said by Darksu, i'd suggest you to try to change your approach from the focus management (which involves not only the tab key but also click events) to an onChange management... still i did not fully understood your context so... well: good luck :)
Giovanni
Hello Zayuke,
Based on your problem i would use the ONCLICK event in order to use a boolean value as a flag, and then i would reset it with a ONMOUSE_OUT event.
https://www.zkoss.org/javadoc/7.0.3/zk/org/zkoss/zk/ui/event/Events.html
This will work with the hypothesis that you will always move your mouse cursor.
Best Regards,
Darksu
Asked: 2016-03-07 09:04:12 +0800
Seen: 35 times
Last updated: Mar 08 '16