Labels in Forms and Reports
Labels are objects that contain static. Most labels are associated with a field, but unassociated labels can be used for any static text on the component.
The name of the label must be unique within the component. It is not possible to have two labels with the same name, even if they are in different entities.
Labels in Form and Report components have properties, such as font, alignment, and transparency. It is not possible to set these properties in ProcScript.
Labels support the use of $text in the Label Text property. This enables you to provide alternate texts, such as a different spelling for American or British audiences, or a translated label for multilingual applications.
Label Layout
You can draw labels anywhere on a form or report component. They do not have to be contained inside an entity or any other object. Labels can overlap the borders of other objects (if the Border property for those objects has been set to Yes or Occurrence). They can also overlap area frames and line frames.
If the width of the label frame is larger than the text it contains, and its background color matches that of the component, Uniface reduces the label to fit the text, exposing any borders otherwise covered by the field. Uniface does not shrink labels that do not meet these criteria, so borders could be obscured, even though the contents of the fields fit within the borders. Label frames are not automatically enlarged to fit the text.
By default, the label rectangle includes a 2 pixel
margin around the text, which can cause the label to wrap, even if there appears to be enough space
for the text. To prevent this from happening, you can set Label Font to FormText
. If you choose to do this, ensure that the FormText font defined in
usys.ini is the same as font0.
Associated Labels
A label that has the same name as a field in the component is said to be an associated or attached label (even if it is not physically attached to the field). Associated labels have several benefits:
- At runtime, clicking an attached label in a form gives focus to its associated field. In the case of check boxes, clicking the label modifies the field value.
- They inherit the Label Text of the field, and the Label Font and Transparency properties from the field widget, so there is no need to separately define the label text.
- You can dynamically change the text of an associated label using the $labelproperties ProcScript function.
- Associated labels are also repeated in every occurrence of the entity.
- You can define an access key for the label, enabling the associated field to be activated by a keystroke.
Dynamic Labels
Except for the text of associated labels (which can be set with $labelproperties), it is not possible to set labels or their properties dynamically.
However, it is possible to create dynamic labels using the Hyperlink widget and setting its properties so that it mimics a label. You can manipulate the Hyperlink field in ProcScript, just as you would any other field. This makes it possible to program its value, location, dimensions, and so on. For more information, see Using Transparent Hyperlinks as Labels .
Internalized Labels
In Form components, associated labels of CheckBox and UnifaceButton widgets can be internalized so that the label becomes part of the widget. To do so the label and the field must be physically attached in the layout, and the dimension of the widget on the side where they attach must be the same. The label then becomes part of the widget and takes on the widget properties.
For a label to be internalized on a check box, that label must be attached to the right side of the widget.
For command buttons, the only reason to internalize a label is because you want to display both an image and text on the label. For a label to be internalized on a command button, the following properties must be set:
- Representation is
Uniface
- Data Type is
Image (any source)
, or one of the specific Image source data types - Field value specifies an image, for example:
@D:\images\Save_16x16.png
For example, start with the following layout where the labels are associated but not physically attached. (The labels have an Index color set.)
When you move the labels so that they touch the fields, the labels are internalized.
Although the color of the labels is still visible in the Layout Editor, it is not visible at runtime: