Adding a Gadget Callback
- Last UpdatedNov 10, 2025
- 2 minute read
To perform intelligent actions a form or gadget must invoke a callback We will now add a simple gadget callback to the hello form.
We will add a second button, change message, which will execute a callback to modify the Message paragraph gadget.
setup form !!hello
paragraph .Message text 'Hello world'
button .change ‘Change message’ callback |!this.message.val = ‘Modified’|
button .bye 'Goodbye' OK
exit

Figure 13:2. A Form with a Gadget Callback
A gadget callback is defined by the callback command followed by a command or PML Function enclosed in text delimiters. As we are giving a text string as part of the command which is itself supplied as a text string, we have had to use two kinds of delimiter: the apostrophe, (‘) and the (|) vertical bar.
Note: The use of This to mean the current form. When the callback is executed,
!this.message.val = ‘Modified’
will set the value member of the gadget Message on this form to read Modified rather than Hello world.
Note: The gadget callback could have been
|!!OtherForm.Para.val = ‘Modified’|
to change the value of a paragraph gadget on another form named !!OtherForm.
Typically a callback will involve many commands and could be a complex piece of code in its own right. In practice, the recommended way of defining a complicated callback is to use a form method.
First though, we need to store our form definition in a file so that we can edit it at will.