DEV Community

Peter + AI
Peter + AI

Posted on

Understanding $ACTIVE_FIELD in Uniface 10.4

*This article was created with the assistance of AI and is based on the official Rocket Software Uniface 10.4 documentation.*

The $ACTIVE_FIELD setting allows developers to control the visual appearance of the field that currently holds focus in a Uniface desktop application. This immediate visual feedback helps users track their cursor position, improving usability in data-heavy forms.

How to Configure $ACTIVE_FIELD

This setting is defined in the [SETTINGS] section of your assignment file (e.g., usys.asn or your application-specific .asn file).

Syntax

$ACTIVE_FIELD {=} Attribute {, Attribute, ...}
Enter fullscreen mode Exit fullscreen mode

Available Video Attributes

The following attributes can be combined to style the active field:

  • HLT: Highlights the field using the system's default highlight color. Note: This attribute takes precedence over other color settings if combined.
  • BOR: Draws a border around the active field.
  • UND: Underlines the text in the field.
  • INV: Inverts the foreground and background colors.
  • BRI: Displays text in a bright or bold weight (device-dependent).
  • COL=n: Applies a specific color combination (see calculation below).

Calculating Custom Colors (COL=n)

If you need a specific color combination instead of the system default (HLT), you must calculate the color code n. Uniface uses a standard formula based on an 8-color palette (indices 0-7).

The Formula

Code = (Foreground × 8) + Background

Color Indices

Index Color
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Brown/Yellow
7 White

Example Calculation

To display White text on a Blue background:

  1. Foreground (White): 7
  2. Background (Blue): 1
  3. Calculation: (7 × 8) + 1 = 56 + 1 = 57
  4. Result: $ACTIVE_FIELD = COL=57

Important Prerequisites & Precedence

Two critical factors determine whether your $ACTIVE_FIELD setting will actually work.

1. The "Cursor Video" Property

The $ACTIVE_FIELD setting is ignored unless the field itself allows it. You must enable the Cursor Video property for the specific field (or model) in the Uniface IDE (Property Inspector > Interface).

2. Precedence Rules (Who Wins?)

When multiple settings try to control the field's appearance, Uniface follows a strict hierarchy. By default, the order of precedence (highest to lowest) is:

  1. ProcScript ($fieldvideo): Code executed in triggers usually overrides assignment settings.
  2. $ACTIVE_FIELD: Your global assignment setting.
  3. $DEF_CUROCC_VIDEO: Settings for the current occurrence.

How to Override ProcScript:

If you want your global $ACTIVE_FIELD setting to always take precedence, even over specific ProcScript commands, add this to your assignment file:

[SETTINGS]
$ACTIVE_FIELD_FIRST = T
Enter fullscreen mode Exit fullscreen mode

Common Pitfalls

  • Web/DSP Limitations: $ACTIVE_FIELD is primarily for Desktop/GUI applications. For Web (DSP) applications, use CSS pseudo-classes like :focus instead.
  • "HLT" Override: If you define $ACTIVE_FIELD = (HLT, COL=57), the HLT attribute will win, and your custom blue background (COL=57) will be ignored.
  • System Themes: The HLT attribute respects the OS theme. On Windows 10/11, this might look different depending on whether the user has Dark Mode or High Contrast mode enabled.

Summary Example

Here is a complete snippet for your usys.asn file:

[SETTINGS]
; Sets the active field to White text on Blue background (57) with a Border
$ACTIVE_FIELD = (COL=57, BOR)

; Optional: Ensures this setting overrides local ProcScript
; $ACTIVE_FIELD_FIRST = T
Enter fullscreen mode Exit fullscreen mode

Top comments (0)