4D v16.3FILTER KEYSTROKE |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
FILTER KEYSTROKE
FILTER KEYSTROKE
FILTER KEYSTROKE enables you to replace the character entered by the user into a field or an enterable area with the first character of the string filteredChar you pass. If you pass an empty string, the keystroke is cancelled and ignored. Usually, you will call FILTER KEYSTROKE within a form or object method while handling an On Before Keystroke form event. To detect keystroke events, use the command Form event. To obtain the actual keystroke, use the commands Keystroke or Get edited text. IMPORTANT NOTE: The command FILTER KEYSTROKE allows you to cancel or replace the character entered by the user with another character. On the other hand, if you want to insert more than one character for a specific keystroke, remember that the text you see on the screen is NOT YET the value of the data source field or variable for the area being edited. The data source field or variable is assigned the entered value after the data entry for the area is validated. It is therefore up to you to “shadow” the data entry into a variable and then to work with this shadow value and reassign the enterable area (see the example in this section). You can also use the Get edited text command. You will use the command FILTER KEYSTROKE for:
WARNING: If you call the command Keystroke after calling FILTER KEYSTROKE, the character you pass to this command is returned instead of the character actually entered. Using the following code: //myObject enterable area object method All the digits entered in the area myObject are transformed into star characters. This code implements the behavior of a Password enterable area in which all the entered characters are replaced (on the screen) by random characters: //vsPassword enterable area object method After the data entry is validated, you retrieve the actual password entered by the user in the variable vsActualPassword. Note: The method Handle keystroke is listed in the Example section for the command Keystroke. In your application, you have some text areas into which you can enter a few sentences. Your application also includes a dictionary table of terms commonly used throughout your database. While editing your text areas, you would like to be able to quickly retrieve and insert dictionary entries based on the selected characters in a text area. You have two ways to do this: This example implements the second solution, based on the Help key. As explained above, during the editing of the text area, the data source for this area will be assigned the entered value after you validate the data entry. In order to retrieve and insert dictionary entries into the text area while this area is being edited, you therefore need to shadow the data entry. You pass pointers to the enterable area and the shadow variable as the first two parameters, and you pass a string of the “forbidden” characters as the third parameter. No matter how the keystroke will be treated, the method returns the original keystroke. The “forbidden” characters are those that you do not want to be inserted into the enterable area and you want to treat as special characters. ` Shadow keystroke project method This method uses the two following submethods: ` Delete text project method After you have added these project methods to your project, you can use them in this way: ` vsDescription enterable area object method The LOOKUP DICTIONARY project method is listed below. Its purpose is to use the shadow variable for reassigning the enterable area being edited: ` LOOKUP DICTIONARY project method The Get highlighted text method is listed here: ` Get highlighted text project method
See also
|
PROPERTIES
Product: 4D
HISTORY
Created: 4D v6 ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||