FOCUS property (System)
Description
Returns the name of the control that currently has focus, or sets the focus to a specified control.
Property Value
A string containing the fully qualified name of the control with focus. When used with Set_Property this value can be the name of WINDOW to activate, and it may also be null to remove the focus from all PS controls.
Property Traits
Development | Runtime | Indexed | Scaled | Synthetic |
---|---|---|---|---|
N/A | Get/Set | No | No | No |
Remarks
Using this property to move the focus to a PS control will trigger the appropriate LOSTFOCUS and GOTFOCUS events. When moving the FOCUS as a result of an error condition (e.g. due to invalid input data) then it is usually desirable to use the BLOCKEVENTS property to stop these events firing, thereby avoiding further validation checks that might send the program into a validation loop.
Example
// Example: Get the current focus FocusCtrl = Get_Property( "SYSTEM", "FOCUS" ) // Example: LOSTFOCUS event to check a code and move the focus // back to the current control if the data is wrong. // // The name of the current control is in the CtrlEntID variable. $Insert Logical CtrlData = Get_Property( CtrlEntID, "TEXT" ) Locate CtrlData In "A,B,C" Using "," Setting Pos Then // Fine - All Good Null End Else Call Msg( @Window, "Bad Data" ) // Move the focus back to this control without triggering // further validation Call Set_Property_Only( "SYSTEM", "BLOCKEVENTS", TRUE$ ) Call Set_Property_Only( "SYSTEM", "FOCUS", CtrlEntID ) Call Set_Property_Only( "SYSTEM", "BLOCKEVENTS", FALSE$ ) End
See Also
Common GUI FOCUS property.