Control characters from pasting

BassoProf

New Member
We're running a mixed GUI and CHUI system with Progress 8.3.

Our users like to paste data into input fields, to avoid typos, but unfortunately they sometimes bring tabs and CR/LFs at the same time, which causes chaos later.

Is there any global setting to prevent entry of these characters, or to filter them out, without having to build validation into every single character input field?

I suppose this version of Progress comes from a time before the widespread use of pasting as an input method, but it seems like an odd oversight to allow in characters that you can't enter from the keyboard.


BassoP
 

tamhas

ProgressTalk.com Sponsor
There are no simple switches, but there are some reasonably simple techniques ... in reasonably modern versions of Progress.
 

trx

Member
Progress inherits global triggers from calling procedure, so you can make use of such trigger (also in 8.3). In startup procedure you define global trigger and then every procedure inherits this trigger until you explicitly override it. By startup procedure I mean either one which you call when starting Progress session or one which is the first in procedure stack (if you want to limit trigger just to some group of programs).
For example:
Code:
ON CTRL-V, SHIFT-INSERT ANYWHERE
DO:
        IF         VALID-HANDLE(FOCUS)
             AND (FOCUS:TYPE = "FILL-IN" OR FOCUS:TYPE = "EDITOR")
             AND FOCUS:DATA-TYPE = "CHARACTER" THEN
      DO:
                FOCUS:SCREEN-VALUE = REPLACE(CLIPBOARD:VALUE, "a", "b").
               RETURN NO-APPLY.
      END.
END.
 

BassoProf

New Member
The trigger works well - but so far only for CHUI programs - the GUI ones must have an override that I have yet to track down.

One slight problem is that the pasted text replaces ALL the content of a fill-in (no big deal) or editor box (a bit more of a problem).

Ideally I'd like to keep standard functionality (insert at cursor, only replace highlighted text), but still have the ability to filter out control characters. Given the choice, I'd take the slightly eccentric behaviour if it protects the database from junk, but I expect some users will complain.

Any ideas?

Code:
/* Remove tabs, CR and LF from pasted text */
ON CTRL-V, SHIFT-INSERT ANYWHERE
DO:
    IF VALID-HANDLE(FOCUS) AND
      (FOCUS:TYPE = "FILL-IN" OR FOCUS:TYPE = "EDITOR") AND
       FOCUS:DATA-TYPE = "CHARACTER" THEN
       DO:
           FOCUS:SCREEN-VALUE = REPLACE(REPLACE(REPLACE(CLIPBOARD:VALUE, CHR(10), ""), CHR(13), ""), CHR(9), " ").
           RETURN NO-APPLY.
    END.
END.
 
Top