Dynamic
Labels
The Problem
Occasionally it becomes necessary to
dynamically change the text displayed in a label. For example, in a
health system, one field could be used for the type of problem
(e.g., eyes, teeth, etc) and another field could be used for the
name of the practitioner, using intelligent labels such as
"Name of Dentist" or "Name of Optician". This
field would need to change its label according to the entered type
of problem, but UNIFACE does not normally allow the content of
labels to be changed at run-time, other than the use of language
variations.
The Solution
One common solution is to use an
Editbox widget, and change its font and properties so it looks like
a label. This will then allow for dynamic content. Although this
appears to resolve the problem, on closer inspection the text
displayed in the Editbox appears on-screen slightly out of position
when compared to normal labels (see example below). Also, if the
cursor is moved over the label, the cursor changes to that of a
text-type cursor, which can be misleading for users.
(Label example - the Editbox "Pretend" label appears
slightly to the left, and slightly lower than a normal label).
A better way to resolve
this problem is to use the Dragsource widget; this widget has been
designed to accommodate dynamic labels directly. To do this, follow
the steps below.
Paste a 1 by 1 Dragsource widget with a
meaningful name. Change its Characteristics to Boilerplate, and
leave all the other properties as default, except for the
"Dynamic Label" checkbox in the "Drag & Drop
Properties" window which should be checked on. Add a
shorthand interface - C1 for example - if you wish to eliminate
the warning message.
Paint your required label (for clarity, next
to the Dragsource widget) and associate it with the Dragsource
widget. The easiest way to do this is to highlight both of them
(via Shift-clicking), pressing the right mouse button and
selecting Labelà Rename As from the pop-up menu.
To populate the label either, use
the second subfield of the Dragsource’s value. For
example, in the proc code assigning the list to the Dragsource
widget, like so:
Dynamic_Drag.Entity = "test=1;Dynamic"
(where ";" - gold
semicolon - is the subfield separator) would assign the value
"Dynamic" to the field’s label. Since the Dragsource
widget itself will not actually be used, and will therefore not
appear, it does not matter what appears in the first part of the
list.
OR set the initial value in the Dragsource
to a list, for example:
|