Returning the control with current/previous input focus (sys.CurrentControl | sys.PrevControl)¶
sys.CurrentControl,,p |
Control with input focus |
sys.PreviousControl,,p |
Control that previously had input focus |
These variables are pointers to the control which currently has input focus and to the control which previously had input focus.
The variables are valid whenever the dialog or input command is active. They can be tested by means of the ?= operator, which returns TRUE if the objects being compared are the same object.
In function calls generated by the events EV_LOSE_FOCUS and EV_VALIDATE, sys.CurrentControl points to the control that is about to receive focus, and sys.PreviousControl points to the control that is losing focus.
If either of these event functions returns the value ERROR, the previous control (the control which was about to lose focus) regains focus. In this case, sys.CurrentControl is set to point to that control, while sys.PreviousControl points to the control that failed to receive focus.
EXAMPLE
The following event function tests whether the current control is the cancel button, in which case validation is not performed.
!function ValEvent(EventCode, Object) { if (EventCode !=EV_VALIDATE) return if (sys.CurrentControl ?= CancelButton) return OKAY return ValidateField(Object) }
This event function, assigned to the cancel button, offers the user a “Cancel dialog” prompt. If this is refused, the function returns the control_id of the control which previously had focus.
!function CancelEvent(EventCode, Object) { if (EventCode != EV_BUTTON_CLICKED) then return prompt "Cancel dialog?" button = "YES" button = "NO", CDERR return CANCEL_DIALOG CDERR: return sys.PreviousControl }
RELATED TOPICS |