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

Details

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.

Example

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 "

Endroutine

Evtroutine Handling(#Cancel.Click)

#Com_owner.CloseForm

Endroutine

End_Com

See also

All Component Classes

Technical Reference