0

I need the onOK event to trigger onKeyUp not onKeyPressed

asked 2016-03-07 09:04:12 +0800

Zayuke gravatar image Zayuke
1 1

updated 2016-03-07 09:14:45 +0800

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.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-03-08 04:47:45 +0800

cor3000 gravatar image cor3000
6280 2 7

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.

link publish delete flag offensive edit
0

answered 2016-03-07 11:36:39 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

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

link publish delete flag offensive edit
-1

answered 2016-03-07 10:51:23 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-03-07 09:04:12 +0800

Seen: 35 times

Last updated: Mar 08 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More