Tech Tip: Dynamically Set Help Tip Text
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: March 1, 2012
Help Tips are used to display a brief message about a field or an object. They appear whenever the mouse hovers over a field or object with an associated Help Tip. As of 4D v13, 4D has the command OBJECT SET HELP TIP. This command can set or even dynamically modify a Help Tip associated with the specified object. Here is an example of how the command can be used:
OBJECT SET HELP TIP(Self->;"This is a help tip") |
In 4D v12, Help Tips need to include variables to allow the text to change dynamically. A variable in a Help Tip must be enclosed in angle brackets (ex. <myVar>).
Here is an example of a variable included in a Help Tip using the Help Tip Editor:
To associate the above Help Tip with an object, use the Property List to select the Help Tip.
The variable in the Help Tip (monthVar) can be set when the mouse enters an object using the Help Tip. For example, the following code is in an object method to set the variable monthVar:
Case of : (Form event=On Mouse Enter) monthVar:="January" End case |
In 4D v13, objects do not need to be associated with a Help Tip. Instead, the above code can simply be replaced with the following:
Case of : (Form event=On Mouse Enter) OBJECT SET HELP TIP(Self->;"January") End case |
The image below shows the Help Tip in action. This is a simple form with one button per each month in the year. In 4D v12, each button is associated with the same Help Tip and the variable inside the Help Tip is being modified. In 4D v13, the Help Tips are set to the associated objects using the OBJECT SET HELP TIP command. Once the mouse hovers over the button, the associated Help Tip will be displayed.