LoseFocus event
Description
Occurs just before a control loses focus (before it becomes
inactive).
Event ID
Event ID |
Description |
---|---|
pbm_controltypekillfocus |
UserObject (standard visual user objects |
pbm_bnkillfocus |
CheckBox, CommandButton, Graph, OLE, |
pbm_cbnkillfocus |
DropDownListBox, DropDownPictureListBox |
pbm_dwnkillfocus |
DataWindow |
pbm_enkillfocus |
SingleLineEdit, EditMask, MultiLineEdit |
pbm_killfocus |
HProgressBar, VProgressBar, DatePicker, MonthCalendar, |
pbm_lbnkillfocus |
ListBox, PictureListBox |
pbm_lvnkillfocus |
ListView |
pbm_renkillfocus |
RichTextEdit |
pbm_sbnkillfocus |
HScrollBar, HTrackBar, VScrollBar, VTrackBar |
pbm_tcnkillfocus |
Tab |
pbm_tvnkillfocus |
TreeView |
Parameters
None
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
Write a script for a control’s LoseFocus event if
you want some processing to occur when the user changes focus to
another control.
For controls that contain editable text, losing focus can
also cause a Modified event to occur.
In a RichTextEdit control, a LoseFocus event occurs when the
user clicks on the control’s toolbar. The control does
not actually lose focus.
Because the MessageBox function grabs focus,
you should not use it when focus is changing, such as in a LoseFocus
event. Instead, you might display a message in the window’s
title or a MultiLineEdit.
Examples
In this script for the LoseFocus event of a SingleLineEdit sle_town,
the user is reminded to enter information if the text box is left
empty:
1 |
IF sle_town.Text = "" THEN |
1 |
   st_status.Text = "You have not specified a town." |
1 |
END IF |
Statements in the LoseFocus event for a DataWindow control dw_emp can
trigger a user event whose script validates the last item the user entered.
This statement triggers the user event ue_accept:
1 |
dw_emp.EVENT ue_accept( ) |
This statement in ue_accept calls the AcceptText function:
1 |
dw_emp.AcceptText( ) |
This script for the LoseFocus event of a RichTextEdit
control performs processing when the control actually loses focus:
1 |
GraphicObject l_control |
1 |
1 |
// Check whether the RichTextEdit still has focus |
1 |
l_control = GetFocus() |
1 |
IF TypeOf(l_control) = RichTextEdit! THEN RETURN 0 |
1 |
1 |
// Perform processing only if RichTextEdit lost focus |
1 |
... |
This script gets the name of the control instead:
1 |
GraphicObject l_control |
1 |
string ls_name |
1 |
l_control = GetFocus() |
1 |
ls_name = l_control.Classname( ) |