Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Default button?
Mon, Jul 9 2012 7:36 AMPermanent Link

Matthew Jones

Is there any way to make a button the "default" button? Or somehow process the
Enter key on the form so that it does some action?

/Matthew Jones/
Mon, Jul 9 2012 12:42 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Is there any way to make a button the "default" button? Or somehow
process the Enter key on the form so that it does some action?  >>

Sure, if you check out the Master-Detail Example (\examples\masterdetail) in
the latest builds, you'll see how this is one with the lookup dialogs
(LookupCust, LookupProduct):

1) Make sure that the form's KeyPreview property is set to True.

2) Add code like this:

function TLookupCustomerDlg.LookupCustomerDlgKeyDown(Sender: TObject; Key:
Integer; ShiftKey, CtrlKey, AltKey: Boolean): Boolean;
begin
  case Key of
     VK_RETURN:
        begin
        ModalResult:=mrOK;
        Result:=False;
        end;
     VK_ESCAPE:
        begin
        ModalResult:=mrCancel;
        Result:=False;
        end;
     else
        Result:=True;
     end;
end;

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Image