Search code examples
openedgeprogress-4glenter

OpenEdge 10.2A - How to apply the default RETURN / CURSOR-DOWN on Editor widget even if a general code for RETURN / CURSOR-DOWN with ANYWHERE exists?


I have a code for RETURN / CURSOR-DOWN for all widgets in a window which basically makes it as if TAB is pressed. It works just fine but I want the default functionality of RETURN (Break current line into two lines) / CURSOR-DOWN for EDITOR widgets.

I have tried to add

APPLY "ENTER" TO SELF.

or

APPLY "RETURN" TO SELF.

or

APPLY "CTRL-J" TO SELF. /*Ctrl-Enter*/

for EDITOR widgets but when pressed RETURN / CURSOR-DOWN in an EDITOR it just does not do anything. It stays as if RETURN / CURSOR-DOWN is not pressed.

ON RETURN OF {&WINDOW-NAME} ANYWHERE
 DO:
    IF SELF:TYPE="EDITOR" THEN
    DO:
        APPLY "ENTER" TO SELF. /*Does NOT Work*/
    END.
    ELSE IF SELF:TYPE = "BUTTON" THEN
     DO:
         APPLY "Choose".
     END.
     ELSE
     DO:
         APPLY "Tab".
         RETURN NO-APPLY.
     END.
 END.  

ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE
DO:
    IF SELF:TYPE="EDITOR" THEN
    DO:
        APPLY "CURSOR-DOWN" TO SELF. /*Does NOT Work*/
    END.
    ELSE
    DO:
        APPLY "Tab".
        RETURN NO-APPLY.
    END.
END.  

Is there a way to do it?


Solution

  • I've tested this in 10.2B08. Here's the main anywhere trigger:

    ON RETURN OF {&WINDOW-NAME} ANYWHERE DO:    
       IF SELF:TYPE = "BUTTON" THEN DO:
          APPLY "Choose".
       END.
       else do: 
          apply 'tab'.
          return no-apply.
       end.
    end.
    ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE DO:
       if self:type ne 'EDITOR' then DO:
          APPLY "Tab".
          RETURN NO-APPLY.
       END.
    END.  
    

    Not much different from what you had. Now in the editor, add a trigger to RETURN and one to CURSOR-DOWN. Here's your editor's RETURN trigger:

    self:insert-string(chr(13)).
    

    And here's the editor's CURSOR-DOWN trigger:

    DEFINE VARIABLE iOffset AS INTEGER     NO-UNDO.
    assign iOffset = self:cursor-char
           self:cursor-line = self:cursor-line + 1 
           self:cursor-char = ioffset no-error.
    do while error-status:get-message(1) begins '**Unable to set attribute CURSOR-CHAR':
       assign iOffset = iOffset - 1
              self:cursor-char = ioffset no-error.
       if iOffset = 1 then leave.
    end.
    

    Let me know if this works for you. Seems to be ok for me here.