In your keydown event add the following (I have an exteaded version I used
within
my controls so I don't have to add it in code all the time)

// The Datasource is the controls datasource //
ShortCutCheckKeyDown(Key, Shift, Datasource);

// Add this procedure to a unit in your library //

Procedure ShortCutCheckKeyDown(var Key: Word;
  var Shift: TShiftState; DbLink: TDatasource);
begin
   {If not connected to a database don't try anything
    or you will get an AV}
   If DbLink = nil then exit;
   If ssctrl in Shift then begin
      If (dblink.state in [dsInsert, dsedit]) then begin
          If key = vk_return then begin
            dblink.dataset.post;
             Key := 0;
             Shift := [];
          end;
      end;
   end;
end;


-----Original Message-----
From: Mark Howard <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Sunday, 28 March 1999 20:00
Subject: [DUG]: Trapping and using a CTRL-ENTER


Hi guys
A simple question.

In variety of controls (StringGrid, ComboBox, EditBox) I want to be able
to detect if the user has pressed a CTRL-ENTER combination.
If he has, I want to invoke the Save procedure. If  CTRL-ENTER is NOT
pressed, the control should just handle the key-press as it usually
does.
This is to save the user having to hunt for the mouse and the SAVE
button, if they prefer.

Can someone please give me a short example of how you would detect and
use this, I can't find any examples of the use of OnKeyDown in the
documentation.
eg (in pseudo code) an OnKeyDown event:
if (Key = Chr(13) and ShiftState  = ssCtrl) then SaveStuff

In a similar vein - is it possible to detect the pressing of TAB before
it does what it does, ie moves focus to the next control?


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to