The documentation for fieldValidationFailed seems to contain an inconsistency regarding field focus.
The dictionary states:
When fieldValidationFailed is sent, the field retains focus so the user can correct the value without having to click back into the field.
However, it also states:
fieldValidationFailed is only sent for user-initiated edits, matching the same conditions under which closeField would fire.
Since closeField is triggered when the field loses focus, it appears that the focus has already changed by the time fieldValidationFailed is sent.
The example provided:
-- Show an inline error and keep the field focused
on fieldValidationFailed pFieldName, pError
set the borderColor of field pFieldName to "red"
show field (pFieldName & "Error")
put pError into field (pFieldName & "Error")
end fieldValidationFailed
displays the validation error correctly, but it cannot actually keep the field focused because the message is received after the focus change.
The expected behavior can be achieved by explicitly restoring the focus:
focus on me
at the end of the handler :
-- Show an inline error and keep the field focused
on fieldValidationFailed pFieldName, pError
set the borderColor of field pFieldName to "red"
show field (pFieldName & "Error")
put pError into field (pFieldName & "Error")
focus on me
end fieldValidationFailed
Could the documentation be clarified to explain that fieldValidationFailed allows the handler to restore focus, rather than implying that the field still has focus when the message is sent?