KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Assigning Tool Tip text dynamically
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: September 7, 2001

A tool tip is a help feature in 4D that will display briefly on an object if you let the mouse pointer hover for a few seconds on the object. You can use tool tips to display a message defined in your structure file. You can see an example of these tool tips if you check the automatic buttons in default input forms that 4D created.

You can create our own tips and define them from the Object property window. However, they are static; you can't change them without re-editing the tip in the Form Editor.

If you want to change tool tips on the fly, you can use the following method:

- Create a 'STR#' resource (String List); for example,
STR# 20000,1 : ID number 20000, element number 1.

- Define the strings in this resource. You can do it from a Mac resource editor application or by using the 4D command ARRAY TO STRING LIST.

- Create a form with one button

- Define a tool tip for this button by using this STR# ID. Name the tip with:
":20000,1"

- Create a script for this button:
ARRAY TEXT(T1;1)
T1{1} := String(random)+"-"+String(random)
ARRAY TO STRING LIST(T1;20000)

- From User mode, display this form.

- If you ask for the tip of this button by placing the mouse pointer over it and waiting for a moment, you will see the text you've defined.

- Click on the button and then re-display the tool tip.

- Now, you can see the random value displayed in this tip.

You have just changed the contents of a tool tip on the fly.

For more information about Tool Tips see:
http://www.4d.com/support/tips01-521.html