Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
ShanePrice Absent Member.
Absent Member.
1493 views

Controls on a Touch Screen

We are using AcuCOBOL-GT 9.2.2 on Windows.  What is the best approach to using the runtime to support use on a touch screen with a physical keyboard available?  Specifically, what is the best way to have an onscreen "10-key" setup of PUSH-BUTTON controls that will feed the number for the button pushed into an ENTRY-FIELD and keep the focus on the entry field?

Here are the two issues we've run across.

1) We can't just use a hard coded tab-value with "set goto-field to true" to move back to the entry-field because there can be more than one entry field on a screen which would need to accept the input from the push-buttons.  If the user clicks into the other entry field, how do we know which one needs to be updated?

2) The second issue is when the user uses the arrow keys on the keyboard.  We don't see an exception, so we don't know that the cursor position has changed.  When you move the cursor with the arrow keys, then click the PUSH-BUTTON, the value gets added to the end since we have no way (that we know of) to know the cursor position within the entry-field.

So, we are looking for how we know which entry-field is active and where the cursor is within the active entry-field.

Below is a simple 10-key example.  It doesn't include on on-screen backspace or clear function, but should give you a good starting point.

Thanks!

IDENTIFICATION DIVISION.
PROGRAM-ID. TST10KEY IS RESIDENT PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FIELD-DATA PIC X(20).
01 TEMP-STRING PIC X(20).
01 10-KEY-NUM PIC 9.
01 KEY-STATUS IS SPECIAL-NAMES CRT STATUS PIC 9(4) VALUE ZERO.
01 10-KEY-WINDOW-HANDLE HANDLE OF WINDOW.

SCREEN SECTION.
01 10-KEY-SCREEN.
03 ENTRY-FIELD VALUE FIELD-DATA LINE 2, COL 2.
03 PUSH-BUTTON TITLE "1" NO-TAB
LINE 4, COL 2, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1001.
03 PUSH-BUTTON TITLE "2" NO-TAB
LINE 4, COL 7, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1002.
03 PUSH-BUTTON TITLE "3" NO-TAB
LINE 4, COL 12, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1003.
03 PUSH-BUTTON TITLE "4" NO-TAB
LINE 7, COL 2, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1004.
03 PUSH-BUTTON TITLE "5" NO-TAB
LINE 7, COL 7, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1005.
03 PUSH-BUTTON TITLE "6" NO-TAB
LINE 7, COL 12, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1006.
03 PUSH-BUTTON TITLE "7" NO-TAB
LINE 10, COL 2, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1007.
03 PUSH-BUTTON TITLE "8" NO-TAB
LINE 10, COL 7, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1008.
03 PUSH-BUTTON TITLE "9" NO-TAB
LINE 10, COL 12, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 1009.
03 PUSH-BUTTON TITLE "0" NO-TAB
LINE 13, COL 2, LINES 2, SIZE 8
SELF-ACT, EXCEPTION-VALUE = 1000.
03 PUSH-BUTTON TITLE "." NO-TAB
LINE 13, COL 12, LINES 2, SIZE 3
SELF-ACT, EXCEPTION-VALUE = 999.
03 PUSH-BUTTON CANCEL-BUTTON
LINE 17, COL 2, SIZE 13.


PROCEDURE DIVISION.
MAIN-LOGIC.
DISPLAY FLOATING GRAPHICAL WINDOW,
TITLE "10-Key Test"
HANDLE IS 10-KEY-WINDOW-HANDLE.

DISPLAY 10-KEY-SCREEN UPON 10-KEY-WINDOW-HANDLE.

PERFORM WITH TEST AFTER UNTIL KEY-STATUS = 27
ACCEPT 10-KEY-SCREEN
ON EXCEPTION CONTINUE
END-ACCEPT

IF KEY-STATUS = 999
MOVE SPACE TO TEMP-STRING
INSPECT FIELD-DATA
REPLACING TRAILING SPACES BY LOW-VALUES
STRING
FIELD-DATA DELIMITED BY LOW-VALUES
"." DELIMITED BY SIZE
INTO TEMP-STRING
ON OVERFLOW CONTINUE
END-STRING
MOVE TEMP-STRING TO FIELD-DATA
DISPLAY 10-KEY-SCREEN
ELSE
IF KEY-STATUS >= 1000 AND KEY-STATUS < 1010
SUBTRACT 1000 FROM KEY-STATUS GIVING 10-KEY-NUM
MOVE SPACE TO TEMP-STRING
INSPECT FIELD-DATA
REPLACING TRAILING SPACES BY LOW-VALUES
STRING
FIELD-DATA DELIMITED BY LOW-VALUES
10-KEY-NUM DELIMITED BY SIZE
INTO TEMP-STRING
ON OVERFLOW CONTINUE
END-STRING
MOVE TEMP-STRING TO FIELD-DATA
DISPLAY 10-KEY-SCREEN
END-IF END-IF
END-PERFORM.

DESTROY 10-KEY-SCREEN.
CLOSE WINDOW 10-KEY-WINDOW-HANDLE.

EXIT PROGRAM.
STOP RUN.

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: Controls on a Touch Screen

Hopefully this may help. For the entry-fields, each one should have a unique id (ID is 1) and each one should have the ntf-changed. By using the ntf-changed you should be able to establish which entry-field is active by inquiring on the ID as well as determining cursor position.

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Controls on a Touch Screen

something along the lines like this:

03 entry-1 ENTRY-FIELD ID is 3 notify-change

       VALUE FIELD-DATA LINE 2, COL 2

       before procedure is ent1-field

       event procedure is ntf-has-happened.

03 entry-2 ENTRY-FIELD ID is 5 notify-change

       VALUE FIELD-DATA LINE 2, COL 32

       before procedure is ent2-field

       event procedure is ntf-has-happened.

..............................................................................

ent1-field.

        inquire entry-1 id = my-value.

ent2-field.

        inquire entry-2 id = my-value.

ntf-has-happened.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.