Hi everyone,
I have a rich display program with a grid and a textbox in each grid row. In the "Onkeydown Event" of the textbox, I would like to trigger a page down key when the cursor focus is in the textbox of the last visible row and the enter key is pressed.
Page down displays the next set of rows (or subfile page) and places the cursor in the first textbox (row) which is exactly what I want.
To find out in which textbox/row the cursor is works and to check whether the enter key is pressed and to prevent the enter key works as well. But how can I trigger the page down key now ?
Is it possible to trigger (or send) a page down or another key with a rich program ? And if so, how ?
I have tried to use pressKey("PageDown") but it didn't work resp. it triggered enter instead. As far as I have read, pressKey only works with Genie.
Is there an alternative to pressKey for rich programs ?
Page Down is key 34.
Thank you very much for your help in advance.
Christoph
How to trigger a page down key ?
-
- Profound User
- Posts: 53
- Joined: Tue Jan 27, 2015 8:13 am
- First Name: Christoph
- Last Name: Seitz
- Company Name: Waser + Co. AG
- Phone: +41 44 94 74 341
- Address 1: Erlenwiesenstrasse 2
- City: Volketswil
- State / Province: Outside Canada/USA
- Zip / Postal Code: 8604
- Country: Switzerland
- Contact:
-
- Profound User
- Posts: 53
- Joined: Tue Jan 27, 2015 8:13 am
- First Name: Christoph
- Last Name: Seitz
- Company Name: Waser + Co. AG
- Phone: +41 44 94 74 341
- Address 1: Erlenwiesenstrasse 2
- City: Volketswil
- State / Province: Outside Canada/USA
- Zip / Postal Code: 8604
- Country: Switzerland
- Contact:
Re: How to trigger a page down key ?
My grid looks like this when executed:
- Attachments
-
- Editor.JPG (79.14 KiB) Viewed 771 times
- Emily
- Profound Logic Staff Member
- Posts: 89
- Joined: Tue Jun 21, 2016 8:30 am
- First Name: Emily
- Last Name: Seage
- Company Name: Profound Logic
- Contact:
Re: How to trigger a page down key ?
Hi Christoph,
The pressKey() API should work for both Genie and for Rich Displays. This is stated in the documentation page we have for the API: http://www.profoundlogic.com/docs/pages ... Id=4849987. Notice that "PageDown" is listed as a valid value for pressKey() when using this with a Rich Display file. So, what you're trying to accomplish should work for you. I was able to set up a quick test using pressKey("PageDown"); and it seemed to page my grid as expected. I suggest checking the code that you are using to make sure there aren't any errors that would prevent this from working properly.
If you continue to have problems with this, please let us know and we'll be happy to assist you further.
Thanks!
The pressKey() API should work for both Genie and for Rich Displays. This is stated in the documentation page we have for the API: http://www.profoundlogic.com/docs/pages ... Id=4849987. Notice that "PageDown" is listed as a valid value for pressKey() when using this with a Rich Display file. So, what you're trying to accomplish should work for you. I was able to set up a quick test using pressKey("PageDown"); and it seemed to page my grid as expected. I suggest checking the code that you are using to make sure there aren't any errors that would prevent this from working properly.
If you continue to have problems with this, please let us know and we'll be happy to assist you further.
Thanks!
Emily Seage
Support Team Lead
Support Team Lead
-
- Profound User
- Posts: 53
- Joined: Tue Jan 27, 2015 8:13 am
- First Name: Christoph
- Last Name: Seitz
- Company Name: Waser + Co. AG
- Phone: +41 44 94 74 341
- Address 1: Erlenwiesenstrasse 2
- City: Volketswil
- State / Province: Outside Canada/USA
- Zip / Postal Code: 8604
- Country: Switzerland
- Contact:
Re: How to trigger a page down key ?
Hi Emily,
Thank you for your answer.
I tried to use PressKey again, but it didn't work unfortunately. When I press the Page Down key it works (the cursor is in the first textbox of the second page), but when I use the PressKey command, it doesn't (the cursor is in the first textbox of the first page instead of the second page).
I have noticed, that for some reason the PressKey causes the program to go back to my RPG program which is not something I want. In my RPG program follows an Exfmt.
Here is my code in the onkeydown event of the textbox:
The code does the following: When enter is pressed, it prevents the enter key and puts the cursor into the next line (textbox) which works. When the cursor is on the last line of the page, textzeile is null. In this case, I would like to send PressKey("PageDown").
The js_StopEnterKeyEvent(event) looks like this:
Thank you for your help in advance.
Christoph
Thank you for your answer.
I tried to use PressKey again, but it didn't work unfortunately. When I press the Page Down key it works (the cursor is in the first textbox of the second page), but when I use the PressKey command, it doesn't (the cursor is in the first textbox of the first page instead of the second page).
I have noticed, that for some reason the PressKey causes the program to go back to my RPG program which is not something I want. In my RPG program follows an Exfmt.
Here is my code in the onkeydown event of the textbox:
Code: Select all
if (js_StopEnterKeyEvent(event)) {
var row2 = row + 1;
var textzeile = getObj("TXT_info" + '.' + row2);
if(textzeile !== null) {
textzeile.focus();
}
if(textzeile === null) {
PressKey("PageDown");
}
}
The js_StopEnterKeyEvent(event) looks like this:
Code: Select all
function js_StopEnterKeyEvent( KeyEvent ) {
var IsStoped = false;
if (KeyEvent != null) {
// Welche Taste wurde gedrückt
var key = KeyEvent.keyCode;
// Enter abfangen
if (key == 13) {
// Enter-Event stoppen
preventEvent(KeyEvent);
IsStoped = true;
}
}
return IsStoped;
}
Christoph
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: How to trigger a page down key ?
Christoph,
The pressKey() API is meant to send a key that would submit a 5250 screen back to the server. It does not simulate a keyboard keypress, but instead always sends control back to the IBM i, and tells the IBM i that the screen was submitted with the given key.
That it why it can only be used with keys that nomally would submit a 5250 screen (F-keys, Enter, PageUp, PageDown, etc) and not with regular letters, numbers, etc. Because it is only the keys that trigger 5250 screens to go back to the server.
If your goal is to scroll a grid, use the grid's scrollToRow() API documented here:
http://www.profoundlogic.com/docs/pages ... d=15728644
The pressKey() API is meant to send a key that would submit a 5250 screen back to the server. It does not simulate a keyboard keypress, but instead always sends control back to the IBM i, and tells the IBM i that the screen was submitted with the given key.
That it why it can only be used with keys that nomally would submit a 5250 screen (F-keys, Enter, PageUp, PageDown, etc) and not with regular letters, numbers, etc. Because it is only the keys that trigger 5250 screens to go back to the server.
If your goal is to scroll a grid, use the grid's scrollToRow() API documented here:
http://www.profoundlogic.com/docs/pages ... d=15728644
-
- Profound User
- Posts: 53
- Joined: Tue Jan 27, 2015 8:13 am
- First Name: Christoph
- Last Name: Seitz
- Company Name: Waser + Co. AG
- Phone: +41 44 94 74 341
- Address 1: Erlenwiesenstrasse 2
- City: Volketswil
- State / Province: Outside Canada/USA
- Zip / Postal Code: 8604
- Country: Switzerland
- Contact:
Re: How to trigger a page down key ?
Scott,
Thank you for your answer.
The scrollToRow() API scrolls to the second page with the first row of the second page on top (which is correct) but the cursor is not in the textbox of the first row of the second page.
This means: The user loses the focus of the cursor and cannot continue to press enter and jump to the next row and then to the next row. The focus is on the whole window and with another enter, control goes back to the rpg program and the user is back on the first page of the grid.
After the scrollToRow, I tried to set the cursor into the textbox of the first row of the second page, but unfortunately I doesn't work after scrollToRow.
Do you know why ?
Do you know how I can set the cursor after scrollToRow ?
Page down jumps to the second page and sets the cursor into the textbox of the first row which is exactly what I would like to achieve.
Thank you for your answer in advance.
Christoph
Thank you for your answer.
The scrollToRow() API scrolls to the second page with the first row of the second page on top (which is correct) but the cursor is not in the textbox of the first row of the second page.
This means: The user loses the focus of the cursor and cannot continue to press enter and jump to the next row and then to the next row. The focus is on the whole window and with another enter, control goes back to the rpg program and the user is back on the first page of the grid.
After the scrollToRow, I tried to set the cursor into the textbox of the first row of the second page, but unfortunately I doesn't work after scrollToRow.
Do you know why ?
Do you know how I can set the cursor after scrollToRow ?
Page down jumps to the second page and sets the cursor into the textbox of the first row which is exactly what I would like to achieve.
Thank you for your answer in advance.
Christoph
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: How to trigger a page down key ?
You may have to use focus() with a timeout to give scrollToRow() time to finish.
Who is online
Users browsing this forum: No registered users and 4 guests