Control - SetFocus Method

Sets the control to be the focus control

Member of Control (PRIM_CTRL)

Details

The SetFocus sets focus to the control.
 
Most focus processing in LANSA is handled automatically, however, on occasion it aids usability to position the cursor to a particular edit.

Example

When clicking a button to show a previously hidden panel, focus would naturally stay with the button that was clicked.
 
SetFocus is used here to position the cursor in the first edit.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Height(397) Left(227) Top(218) Width(582) Clientwidth(566) Clientheight(358)
   Define_Com Class(#PRIM_PANL) Name(#Editor) Displayposition(2) Left(7) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(39) Height(306) Width(554) Visible(False)
   Define_Com Class(#EMPNO.Visual) Name(#EMPNO) Componentversion(1) Displayposition(1) Height(21) Left(13) Parent(#Editor) Tabposition(1) Top(12) Usepicklist(False) Width(251)
   Define_Com Class(#SURNAME.Visual) Name(#SURNAME) Displayposition(2) Left(13) Parent(#Editor) Tabposition(2) Top(34)
   Define_Com Class(#GIVENAME.Visual) Name(#GIVENAME) Displayposition(3) Left(13) Parent(#Editor) Tabposition(3) Top(56)
   Define_Com Class(#ADDRESS1.Visual) Name(#ADDRESS1) Displayposition(4) Left(13) Parent(#Editor) Tabposition(4) Top(78)
   Define_Com Class(#ADDRESS2.Visual) Name(#ADDRESS2) Componentversion(1) Displayposition(5) Height(21) Left(13) Parent(#Editor) Tabposition(5) Top(100) Usepicklist(False) Width(537)
   Define_Com Class(#ADDRESS3.Visual) Name(#ADDRESS3) Componentversion(1) Displayposition(6) Height(21) Left(13) Parent(#Editor) Tabposition(6) Top(122) Usepicklist(False) Width(537)
   Define_Com Class(#POSTCODE.Visual) Name(#POSTCODE) Componentversion(1) Displayposition(7) Height(21) Left(13) Parent(#Editor) Tabposition(7) Top(144) Usepicklist(False) Width(266)
   Define_Com Class(#PRIM_PHBN) Name(#ShowHideEditor) Caption('Show Editor') Displayposition(1) Left(8) Parent(#COM_OWNER) Tabposition(1) Top(6)
 
   Evtroutine Handling(#ShowHideEditor.Click)
 
      If (#Editor.Visible)
 
         #ShowHideEditor.Caption := "Show Editor"
         #Editor.visible := False
 
      Else
 
         #ShowHideEditor.Caption := "Hide Editor"
         #Editor.visible := True
         #EMPNO.SetFocus
 
      Endif
 
   Endroutine
 
End_Com

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020