Page 1 of 1

Intercept the enter key?

Posted: Mon Mar 09, 2015 4:35 pm
by rmarsh
We have a situation where a field requires a field exit then an enter. Is it possible to intercept the enter key and change the function?

I'm not sure how one would know if the user was in the appropriate field or not. Is there anything like CSRLOC in Genie?

Re: Intercept the enter key?

Posted: Mon Mar 09, 2015 5:07 pm
by Scott Klement
CSRLOC should work the same in Genie as it does in any other 5250 emulator. Not sure how that helps, here, unless you want to handle the change in your RPG program.

Every field has a whole bunch of JavaScript events that you can code for. For example "onkeydown" would be run when the user presses a key. You could have code in the onkeydown for a particular field that does something like this:

Code: Select all

if (event.keyCode == 13) {
   pui.fieldExit();
}
In this case, when the user hits enter (which is character code 13), it runs the "pui.fieldExit()" API. After that is complete, the ENTER will still be processed as normal (because I didn't prevent the default action from occurring... though, you could.)

Re: Intercept the enter key?

Posted: Tue Mar 10, 2015 10:01 am
by rmarsh
That's what I needed. Thank you.