Push Button - ButtonDefault Property

Set to true to fire the click event when the enter key is pressed

Member of Push Button (PRIM_PHBN)

Data Type - Boolean


The ButtonDefault property associates the button to the Enter key.
When True, pressing the Enter key will fire the Click event, unless focus has been moved to another button.
Only one button can be set to True.


This form shows the use ButtonDefault and ButtonCancel
Whenever Enter is pressed, "OK " is added to the caption.  Whenever the Escape key is used, the form closes.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(387) Clientheight(161) Componentversion(2) Top(228) Left(267)
   Define_Com Class(#PRIM_PHBN) Name(#OK) Caption('&OK') Displayposition(1) Left(206) Parent(#COM_OWNER) Tabposition(1) Top(128) Buttondefault(True)
   Define_Com Class(#PRIM_PHBN) Name(#Cancel) Caption('&Cancel') Displayposition(2) Left(303) Parent(#COM_OWNER) Tabposition(2) Top(128) Buttoncancel(True)
   Evtroutine Handling(#OK.Click)
      #Com_owner.Caption += "OK "
   Evtroutine Handling(#Cancel.Click)

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020