How Do I Set Logic to Be Executed When the End User Writes Data in a Control? (Magic xpa 3.x)
Usually in Magic xpa, the data in an edit field is stored in the variable after the cursor leaves the field. But sometimes you may need to capture data while the user is still typing. A common example is shown here, in a comments box. The comment space is limited, and the user sees the number of “characters remaining” decrease as they type.
It is simple to implement this kind of interactive capture:
-
Create an Event handler. This will capture the Internal event, Control Modify, on the field that you want to capture.
-
Within the handler, fetch the data that the user is entering with the EditGet() function. In this instance, we are capturing the length of the field, so we use Len(EditGet()).
You can modify the logic for a variety of purposes, such as creating interactive “best match” lists or error checking.
Note: A variable is updated with the new value only when leaving the control. This is the reason for using the EditGet() and not the variable itself.
The Online and Rich Client Samples projects (program LG18 and RLG18)