KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: New Form Event On After Edit in 2004.2
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: July 29, 2005

There is a new form event available in 4D 2004.2 that allows the developer to capture when text has been pasted into a variable or field. Previously, only text that was typed into a variable/field could be captured. This new behavior provides more control to the developer to prevent the entry of unwanted characters, ease the ability to build complex undo features for cut/pasted text, and dragged text capture from outside applications, and more. Here are some examples that display benefits of this form event:

`````````````````````````````````````

`Object Method: MyEntryField

`Description: restrict password to 16 characters

`````````````````````````````````````

Case of

: (Form event=On After Keystroke ) | (Form event=On After Edit )

   If (Length(Get edited text)>16)

    Self->:=Substring(Get edited text;1;16)

  End if

End case

`````````````````````````````````````

`Object Method: MyDisplayField

`Description: Allow user to highlight field (for copying, etc) but do not allow modification

`````````````````````````````````````

Case of

: (Form event=On Before Keystroke ) | (Form event=On After Edit )

  FILTER KEYSTROKE("") ` so users can't type and see the cursor move

  C_TEXT($text)

  $text:=Self->


  ` so users can't paste text into the variable

  If ($text#Get edited text)

    Self->:=$text

  End if

End case