A customer app built in Uniface 10 got a quick entry form: while the user moves from field to field, the form tidies names, checks the e-mail address, fills in the city from the postal code and lists similar customers. All of that runs in field triggers. The first version did nothing at all, and the compiler did not complain.
Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026.
The trigger that never ran
The field script of the postal code field looked like this:
trigger leaveField
call LEAVE_POSTAL
return 0
end
Compile: 0 errors, the usual warning about the non-modeled entity. Run: nothing. The buttons on the same form, whose field scripts use trigger detail, worked fine.
The reason is the trigger name. Uniface 10 renamed the interactive field triggers. The one that fires when the cursor leaves a field is now loseFocus:
| Uniface 9 | Uniface 10 |
|---|---|
| Field Gets Focus | getFocus |
| Field Loses Focus | loseFocus |
| Validate | validate |
| Detail | detail |
| Value Changed | valueChanged |
(From the Uniface 10 documentation, "Changes in Triggers".)
leaveField is not one of them, yet the compiler accepted it. In my setup it compiled without an error or a warning, the name even shows up in the compiled form, and it is simply never called. If a field trigger seems dead, check its name first.
The working version:
trigger loseFocus
call LEAVE_POSTAL
return 0
end
and the entry it calls, from the form's component script:
entry LEAVE_POSTAL
variables
string vMsg, vCity
numeric vN
endvariables
if (F_POSTAL.QCU_DMY = "")
return 0
endif
activate "ENTRY_SVC".CHECK_POSTAL(F_POSTAL.QCU_DMY, F_COUNTRY.QCU_DMY, vMsg)
if ($status = 1)
INFO.QCU_DMY = vMsg
return 0
endif
activate "ENTRY_SVC".CITY_FOR_POSTAL(F_POSTAL.QCU_DMY, F_COUNTRY.QCU_DMY, vCity, vN)
if (vCity = "")
INFO.QCU_DMY = "No address with this postal code yet."
return 0
endif
if (F_CITY.QCU_DMY = "")
F_CITY.QCU_DMY = vCity
if (vN > 1)
INFO.QCU_DMY = "City filled in; %%(vN) different cities are known for this postal code."
else
INFO.QCU_DMY = "City filled in from existing addresses."
endif
else
if ($lowercase(F_CITY.QCU_DMY) != $lowercase(vCity))
INFO.QCU_DMY = "Existing addresses with this postal code use the city %%(vCity)."
endif
endif
return 0
end
loseFocus runs whether or not the value was changed, so the entry returns early when the field is empty and does not overwrite a city the user typed (it only mentions a different one).
Double-click on an edit box
The tag field should show suggestions on double-click, so it got trigger detail. That did not run either. In an edit box, a double-click selects a word by default. The widget property Double-Click (DblClk) decides; with the value Detail it fires the detail trigger. It can be set at runtime, for example in exec:
$fieldproperties(F_TAG.QCU_DMY) = "DblClk=Detail"
The keyboard function for ^DETAIL fires the trigger regardless of this setting.
Where the field script lives in an XML export
The form is generated and imported as XML. A field trigger is not part of the component script; it sits in the USCRIPT element of that field's occurrence, next to the widget type:
<DAT name="ULABEL">F_POSTAL</DAT>
...
<DAT name="USCRIPT" xml:space='preserve'>trigger loseFocus
call LEAVE_POSTAL
return 0
end
</DAT>
<DAT name="FRM_WIDGETTYPE">EDITBOX</DAT>
Keep that in mind when you compare repository sources with files: a tool that only looks at the component script will not see field triggers.
Two more observations
- Field triggers run inside the form, so a value assigned to the field in the trigger is visible immediately.
- In these generated forms the Tab key also stops on label fields. Clicking into the next field fires
loseFocusjust as reliably.
Summary
- Use the Uniface 10 trigger names:
loseFocus,getFocus,validate,detail,valueChanged. - An unknown trigger name compiles quietly. Test that each trigger runs at least once.
- Set
DblClk=Detailon edit boxes that should react to a double-click.
Top comments (0)