Occurs just before a control loses focus (before it becomes inactive).
Event ID |
Description |
---|---|
pbm_controltypekillfocus |
UserObject (standard visual user objects only) |
pbm_bnkillfocus |
CheckBox, CommandButton, Graph, OLE, Picture, PictureHyperLink, PictureButton, RadioButton, StaticText, StaticHyperLink |
pbm_cbnkillfocus |
DropDownListBox, DropDownPictureListBox |
pbm_dwnkillfocus |
DataWindow |
pbm_enkillfocus |
SingleLineEdit, EditMask, MultiLineEdit |
pbm_killfocus |
HProgressBar, VProgressBar, DatePicker, MonthCalendar, InkEdit, InkPicture |
pbm_lbnkillfocus |
ListBox, PictureListBox |
pbm_lvnkillfocus |
ListView |
pbm_renkillfocus |
RichTextEdit |
pbm_sbnkillfocus |
HScrollBar, HTrackBar, VScrollBar, VTrackBar |
pbm_tcnkillfocus |
Tab |
pbm_tvnkillfocus |
TreeView |
None
Long. Return code choices (specify in a RETURN statement):
0 Continue processing
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.
Example 1 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:
IF sle_town.Text = "" THEN
st_status.Text = "You have not specified a town."
END IF
Example 2 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:
dw_emp.EVENT ue_accept( )
This statement in ue_accept calls the AcceptText function:
dw_emp.AcceptText( )
This script for the LoseFocus event of a RichTextEdit control performs processing when the control actually loses focus:
GraphicObject l_control
// Check whether the RichTextEdit still has focus
l_control = GetFocus()
IF TypeOf(l_control) = RichTextEdit! THEN RETURN 0
// Perform processing only if RichTextEdit lost focus
...
This script gets the name of the control instead:
GraphicObject l_control
string ls_name
l_control = GetFocus()
ls_name = l_control.Classname( )