Cursor position

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Roger

Cursor position

Post by Roger »

Hi,
I have some programs where the programs detect the position of the cursor and act accordingly.
For example, you can position the cursor on line 10 and press F1 to get more details about the content of line 10.
How can this be maintained?
I know that some of this can be transferred to the front-end but if I want the program to maintain control, how can this be done?
Thanks,
Roger
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Cursor position

Post by Alex »

Hi Roger,

Profound UI uses several techniques to handle this:

1) Each element can be assigned a "cursor row" and a "cursor column" property

2) When the user clicks an element or an input element receives focus, these values are captured and sent to the server when a response is submitted

3) Server code can retrieve the values by using the INFDS data structure, or through screen level properties named "return cursor row" and "return cursor column"

4) In addition, Profound UI also supports properties named "return cursor record" to retrieve the record format and "return cursor field" to retrieve the field where the cursor resides

5) When working with grids, cursor location can be determined using the "cursor record number" property, which provides the relative record number of the record on which the cursor is located.

The DDS conversion module will automatically translate the appropriate DDS keywords, such as RSTNCSRLOC and SFLCSRRRN, to the equivalent properties in Profound UI.

The above techniques allow you to work with cursor positions at the program (RPG) level. In addition, the platform supports a variety of front-end JavaScript events, such as onclick and onfocus, which can allow you to accomplish some of the same functionality with JavaScript.
swushw
New User
Posts: 12
Joined: Thu Apr 11, 2013 5:58 pm
First Name: Shirley
Last Name: Wijaya
Company Name: US HealthWorks
State / Province: California
Contact:

Re: Cursor position

Post by swushw »

Hello,

I need to determine the cursor location in a grid, the row as well as the column. I know how to get the row value but not the column. Return Cursor Location property is not available for a grid. What are my options?

Thanks.
Scott Klement
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: Cursor position

Post by Scott Klement »

Typically, you'd get the row number of a grid using the "cursor record number" property. (This is equivalent to the SFLCSRRRN DDS keyword in green-screen.) Bind that to an variable, and it'll be returned to your RPG program.

If your display was converted from a green-screen DDS, then the "cursor row" and "cursor column" properties of each of the fields in the subfile (text boxes, labels, etc -- not the subfile itself) should be filled in from when the conversion was done. (You could also potentially fill these in yourself if your display was not converted.) There are screen-level properties called "return cursor row" and "return cursor column" which could be used to return these values. The "row" value is probably not useful in a subfile (use the cursor record number instead) , but the column value would be.

Or did you try that, and it didn't work?
swushw
New User
Posts: 12
Joined: Thu Apr 11, 2013 5:58 pm
First Name: Shirley
Last Name: Wijaya
Company Name: US HealthWorks
State / Province: California
Contact:

Re: Cursor position

Post by swushw »

Hi Scott,

Since "return cursor column" property is not available for grids, how does it work in a grid?

I have tried the "cursor column" properties but it didn't work. I may not have done it correctly. Would you please provide me with the details on how "cursor column" works?

Thanks.
Scott Klement
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: Cursor position

Post by Scott Klement »

I think it's useful to understand that a web page doesn't have the same sorts of rows/columns that a 5250 screen would have. A 5250 screen is always (ROWSxCOLS) 80x24 or 132x27. Each spot in this grid is one text cell that can contain one character (letter, number, punctuation, etc.)

Web pages do not work that way. The screen is not divded into rows/columns of text values. Rather, it's divided into pixels, and a given screen is unlimited in size in both height and width. If you exceed the number of pixels across or down the browser window, it simply uses scrollbars to allow an unlimited size screen.

Text, graphics, and widgets are not positioned in predetermined "cells". They can go at any pixel position. They can also go right on top of each other. And when you do use text, it's not a fixed size (or font) you can have many different types of text on the same screen, and they can be at any pixel position (including on top of other text) in the screen.

But, since many (almost all, actually) of Profound logic's customers are converting from green screen, it's important for us to be able to provide some way to achieve backward compatibility with the columns/rows that you had in the old environment. So what we did is add a "cursor column" and "cursor row" property to every widget that you can stop the cursor on. The system doesn't truly detect what column you're on... you have to assign the column number in the widget. (Though, if you convert from a green-screen display file, the converter will automatically populate the "cursor row" and "cursor column" properties after it reads them from the green-screen display file.)

When you bind a field to the "return cursor column" and/or "return cursor row" properties (which are "screen-level" properties... i.e. properties that correspond to the record format rather than an individual widget) then these will be used to return the "cursor column" and "cursor row" values to the program. So if you have a textbox (for example) that has cursor row = 1, cursor column = 10, and the user positions to that textbox and hits ENTER, the RPG program will get "return cursor row = 1" and "return cursor column = 10" in it's bound variables.

But, PUI doesn't really know which row/col the cursor is on. It can't, because it's a web application not a 5250 application. It just returns whatever you coded into the "cursor row/col" properties of the widget. Hope that makes sense.

So here's an example. I created a grid, and I want to know which column and row the user left the cursor on. I build my screen in the visual designer, like this:
rowcol1.png
rowcol1.png (28.38 KiB) Viewed 15426 times
Hopefully you can see that I set the "cursor column" to 1 for the first column of the subfile. I also set it to 2 and 3 for the other two columns. So heading A=1, heading B=2, heading C=3. I did this simply by typing 1 into the cursor column attribute of the textbox that's in the first row of column A, typing 2 into the cursor column for the textbox in B, and 3 into the textbox in column C.

To get back the column number into my RPG program, I've bound a variable named "COL" to the "return cursor column" screen property.
rowcol2.png
rowcol2.png (7.26 KiB) Viewed 15426 times
To get back the row number into my RPG program, since this is a subfile that can have thousands of rows, I don't want to use the "return cursor row". Instead, I'll use the RRN of the subfile, which I can get with the "cursor record number" property of the subfile itself.
rowcol3.png
rowcol3.png (7.58 KiB) Viewed 15426 times

Just for the sake of a simple example, I put output fields at the bottom that I can use to see what row/column were the last time the user hit ENTER. The RPG code simply loads test data into the subfile, and then copies the row/col values to the labels (lblRow, lblCol) at the bottom of the screen.

Code: Select all

     H DFTACTGRP(*NO)

     FROWCOL    CF   E             WORKSTN EXTDESC('SKTEST/ROWCOL')
     F                                     EXTFILE('SKTEST/ROWCOL')
     F                                     SFILE(SFL: RRN)
     F                                     HANDLER('PROFOUNDUI(HANDLER)')

     D RRN             S              4  0
      /free
         ClearSFl = *on;
         write REC;
         ClearSfl = *off;
         RRN = 0;

         for RRN = 1 to 1000;
            DATA1 = 'COLA' + %Char(rrn);
            DATA2 = 'COLB' + %Char(rrn);
            DATA3 = 'COLC' + %Char(rrn);
            write SFL;
         endfor;

         dou btnExit = *on;
            lblRow = Row;
            lblCol = Col;
            exfmt REC;
         enddo;

         *inlr = *on;
When I run this, I can move the cursor to any of the textboxes in the subfile and press enter. The screen then refreshes, showing the row/col that I was at by printing it in the labels at the bottom of the screen.

Does that help you understand it?
swushw
New User
Posts: 12
Joined: Thu Apr 11, 2013 5:58 pm
First Name: Shirley
Last Name: Wijaya
Company Name: US HealthWorks
State / Province: California
Contact:

Re: Cursor position

Post by swushw »

Thanks so much Scott. I appreciate your time explaining it in great length.

Have a wonderful weekend.
sherimc
New User
Posts: 7
Joined: Mon Jun 05, 2017 1:03 pm
First Name: sheri
Last Name: mcpherson
Company Name: winsupply
Contact:

Re: Cursor position

Post by sherimc »

Scott,
This is the most detail example I can find on how we could get this to work, but as hard as I try I cannot get the Return Cursor Column to return a valid number every time.

I have a subfile grid with 4 columns. The first column is a phone number, the second column is only holding an image for clicking a "trash can", the third column is Email Address, the fourth column is another image clicking the "trash can".

I set the Phone Number column property Cursor Column to 1. I set the Email Address column property Cursor Column to 2.

The RPG program will sometimes return the right column, but in most instances it is wrong. I cannot use this accurately.

Even if it did send the correct column, how can I tell Profound to "go to Column 2" if I am on Column 1 or vise versa? It simply doesn't work.

I have tried setting several properties like Set Cursor Column and it never works.

Thanks for any input.
Sheri
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests