Delphi: How to disable TAction keyboard shortcuts?

I am using Delphi TActionList with shortcuts for some actions.

I want some actions to be triggered several times using automatic keyboard repeat, but I don’t want to influence the automatic repeat operation in the whole world. What is the best way to do this?

Clarification . I still need to handle some quick keystrokes - these are just auto-repeat keystrokes that I want to ignore.

+3
source share
3 answers

Intercept WM_KEYDOWN messages and look at bit 30 to see if it is automatically repeating. If so, just do not send the message as usual, and it will not be visible.

You may need to enable the key-preview form to make this work.

+12
source

You can remove TTimer, set the TTimer.Interval value you want (1000 = 1sec), and then do something like this in the TActionList:

procedure TfrmMain.ActionList1Execute(Action: TBasicAction; var Handled: Boolean);
begin
  if Timer1.Enabled then 
  begin
    Handled := True;
    Exit;
  end;

  Handled := false; 
  Timer1.Enabled := true;     
end;

Also remember to disable the timer in Timer.OnTimer .

+2
source

, , , . :

procedure TForm.FormCreate(const Sender: TObject);
begin
  // ...

  FLastActionTime := Now; // 
end;

proceudure TForm.Action1Execute(const Sender: TObject);
const
  cThreshold = 1/(24*60*60*10); // 0.1 sec
begin
  if Now-FLastActionTime<cThreshold then
    Exit; // Ignore two actions within 0.1 sec
  FLastActionTime := Now;
end;

dmajkic, aproach. , TAction/TActionlist.

0
source

Source: https://habr.com/ru/post/1702582/


All Articles