Question ESC key in frame

whwar9739

Member
Trying to find a way to catch the esc key in a frame defined as a dialog-box. Thus far my efforts have either done nothing, or closed the entire application rather than just the immediate dialog box. I have tried 'ON ESC OF FRAME Dialog-Frame', 'ON ENDKEY OF FRAME Dialog-Frame', and 'ON END-ERROR OF FRAME Dialog-Frame'.

TIA
Whwar9739
 

TomBascom

Curmudgeon
What platform are you attempting to do this on?

Perhaps a snippet of sample code might be in order?
 

whwar9739

Member
Working with Progress 11.2.1. The frame is tied to an active window. Let's see what I can for snippets of code, lol.

Code:
DEFINE FRAME Dialog-Frame
    txtCopies AT ROW 2.43 COL 6.8 COLON-ALIGNED NO-LABEL
    l-msg AT ROW 1.29 COL 6.2 COLON-ALIGNED NO-LABEL
    copies AT ROW 2.43 COL 11.6 COLON-ALIGNED NO-LABEL
    IMAGE-3 AT ROW 1 COL 1
    SPACE(18.99) SKIP(1.56)
    WITH VIEW-AS DIALOG-BOX KEEP-TAB-ORDER
        SIDE-LABELS NO-UNDERLINE THREE-D  SCROLLABLE
        TITLE "Print".


ON WINDOW-CLOSE OF FRAME Dialog-Frame /* Print */
DO:
   l-close = YES.
   APPLY "END-ERROR":U TO SELF.
END.


ON ANY-PRINTABLE OF txtCopies IN FRAME Dialog-Frame
DO:
   IF KEYFUNCTION(LASTKEY) = "0"
   THEN DO:
      ASSIGN txtCopies:SCREEN-VALUE = "0".
      l-cancel = Yes.
      PROCESS EVENTS.
   END. /* IF KEYFUNCTION(LASTKEY) = "0" */
END.


ON LEAVE OF txtCopies IN FRAME Dialog-Frame
DO:
   IF INT(txtCopies:SCREEN-VALUE) = 0
   THEN DO:
      l-cancel = Yes.
   END. /* IF INT(txtCopies:SCREEN-VALUE) = 0 */ 
END.

To add to the complexity, txtCopies is not always available, and in fact the specific issue I am having is when it's hidden attribute is set to YES.
When txtCopies is not hidden the esc key functions as expected and closes just the window and not the entire application.

Also most of this is code that built using the AppBuilder, not sure if that will make any difference or not.
 

Osborne

Active Member
If any help, for dialog boxes I do something like this:
Code:
ON END-ERROR, ENDKEY OF FRAME Dialog-Frame
DO:
   DISABLE ALL WITH FRAME Dialog-Frame.
   HIDE FRAME Dialog-Frame NO-PAUSE.
   RETURN NO-APPLY.
END.
 

whwar9739

Member
If any help, for dialog boxes I do something like this:
Code:
ON END-ERROR, ENDKEY OF FRAME Dialog-Frame
DO:
   DISABLE ALL WITH FRAME Dialog-Frame.
   HIDE FRAME Dialog-Frame NO-PAUSE.
   RETURN NO-APPLY.
END.


Ok I tried adding something extremely similar to this and still nothing. Below are snippets of the progress logs. First one is when the txtCopies is available and the second one is when the txtCopies is set to hidden. This does have the code from above in it, note the begin/end-trigger. Oh and I removed the program name.

***WITH txtCopies:HIDDEN = NO***
[13/09/04@15:19:54.732-0500] P-007472 T-006580 3 4GL PROEVENTS START GUI WM_KEYDOWN FILL-IN txtCopies
[13/09/04@15:19:54.732-0500] P-007472 T-006580 3 4GL PROEVENTS START GUI WM_CHAR ESC FILL-IN txtCopies
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS PUSH ESC (END-ERROR) FILL-IN txtCopies
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS PUSH ESC (END-ERROR) DIALOG-BOX Dialog-Frame Handle:10122
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS Begin-Trigger "ESC (END-ERROR) OF DIALOG-BOX Dialog-Frame" Handle:10122
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS End-Trigger "ESC (END-ERROR) OF DIALOG-BOX Dialog-Frame" Handle:10122
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS PRGS ESC (END-ERROR) DIALOG-BOX Dialog-Frame Handle:10122 discarded return no-apply
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS POP ESC (END-ERROR) DIALOG-BOX Dialog-Frame Handle:10122
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS PRGS ESC (END-ERROR) FILL-IN txtCopies discarded
[13/09/04@15:19:54.732-0500] P-007472 T-006580 2 4GL PROEVENTS POP ESC (END-ERROR) FILL-IN txtCopies

----------------------------

***WITH txtCopies:HIDDEN = YES***
[13/09/04@15:19:56.909-0500] P-007472 T-006580 3 4GL PROEVENTS START GUI WM_KEYDOWN DIALOG-BOX Dialog-Frame Handle:10139
[13/09/04@15:19:57.418-0500] P-007472 T-006580 2 4GL PROEVENTS PROCESS EVENTS [print-doc]
[13/09/04@15:19:57.418-0500] P-007472 T-006580 3 4GL PROEVENTS START GUI WM_KEYDOWN DIALOG-BOX Dialog-Frame Handle:10139
[13/09/04@15:19:57.928-0500] P-007472 T-006580 2 4GL PROEVENTS PROCESS EVENTS [print-doc]
[13/09/04@15:19:57.928-0500] P-007472 T-006580 3 4GL PROEVENTS START GUI WM_KEYDOWN DIALOG-BOX Dialog-Frame Handle:10139
 

Cringer

ProgressTalk.com Moderator
Staff member
Did you have the RETURN NO-APPLY line? I think this is important.
 

Osborne

Active Member
What is the MAIN-BLOCK code like? Does it differ much from the standard AppBuilder code for dialog boxes which always seems to work okay when the Esc key is pressed?:
Code:
MAIN-BLOCK:
DO ON ERROR  UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
   RUN enable_UI.
   WAIT-FOR GO OF FRAME {&FRAME-NAME}.
END.
RUN disable_UI.
 

Osborne

Active Member
I do not know if this is relevant, but from your Progress logs it appears the Esc key is being recorded as an END-ERROR event. In this simple test I tried in a standard AppBuilder Dialog Box creation the event says it is ENDKEY when I press the Esc key:
Code:
ON END-ERROR OF FRAME Dialog-Frame /* Dialog Box */
OR ENDKEY OF FRAME Dialog-Frame
DO:
   MESSAGE LAST-EVENT:FUNCTION VIEW-AS ALERT-BOX INFORMATION.
   RETURN NO-APPLY.
END.
 

whwar9739

Member
I do not know if this is relevant, but from your Progress logs it appears the Esc key is being recorded as an END-ERROR event. In this simple test I tried in a standard AppBuilder Dialog Box creation the event says it is ENDKEY when I press the Esc key:
Code:
ON END-ERROR OF FRAME Dialog-Frame /* Dialog Box */
OR ENDKEY OF FRAME Dialog-Frame
DO:
   MESSAGE LAST-EVENT:FUNCTION VIEW-AS ALERT-BOX INFORMATION.
   RETURN NO-APPLY.
END.

Yes it gets caught as an END-ERROR but only when the FILL-IN is *not* hidden.
 

whwar9739

Member
What is the MAIN-BLOCK code like? Does it differ much from the standard AppBuilder code for dialog boxes which always seems to work okay when the Esc key is pressed?:
Code:
MAIN-BLOCK:
DO ON ERROR  UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
   RUN enable_UI.
   WAIT-FOR GO OF FRAME {&FRAME-NAME}.
END.
RUN disable_UI.

Similar except we have some additional business logic and no WAIT-FOR line.
 
Top