Secondary label does not work

I am using Delpho 2006. Scenario:

In the data module, I have an ActionList. One of the actions has the keyboard shortcut Ctrl + F4, and I want to have an additional shortcut Ctrl + W. I tried all of the following:

Adding Ctrl + W to the SecondaryShortcut action list in the IDE.

Adding it to a DataModuleCreate procedure using

ActFileCloseFile.SecondaryShortCuts.Add('Ctrl+W');

or

ActFileCloseFile.SecondaryShortCuts.AddObject('Ctrl+W',
  TObject(Menus.ShortCut(87, [ssCtrl])));

Using both of these methods in the Create or FormShow procedure of the form in which it will be used.

The main shortcut always works, but not secondary.

When I put an ActionList in the main form instead of a data module, it works by simply adding Ctrl + W to the IDE. What am I doing wrong?

+3
4

, :

, SecondaryShortCut, OnShortCut:

procedure TMyForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
  Handled := dmDataModule.ActionList1.IsShortCut(Msg);
end;

:

( , .)

, , . . .

Ctrl + W SecondaryShortCuts, IDE.

, , .

+3

, datamodule mainform, :

procedure TMainForm.FormCreate(Sender: TObject);
begin
  FDataModule := TMyDataModule.Create(self);
  TMyButton.Action := FDataModule.TheAction;
end;


procedure TMyDataModule.DataModuleCreate(Sender: TObject);
begin
  TheAction.SecondaryShortCuts.Add('Ctrl+W');
end;

, , . , , , , .

+1

: .

, , . , . , , OP , .

:

  • .
  • .

. , Action ( ShortCut). TMenuItem . , .


; , . , , . , , .

. , , , . , , : ShortCut SecondaryShortcuts. ( , .)

...

, ?

. , , .

  • ( ) , . , .

  • , . , .

. , . , , . .

  • , , , . ( , ). , Owner .

.. :

Application.CreateForm(TDataModule1, DataModule1);

:

DataModule1 := TDataModule1.Create(LocalForm);

, : , . , . , .

  • , , - OP. , " ", OnShortCut :

, .

procedure TMyForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
  Handled := DataModule1.ActionList3.IsShortCut(Msg);
  Handled := Handled or DataModule2.ActionList1.IsShortCut(Msg);
  Handled := Handled or DataModule1.ActionList1.IsShortCut(Msg);
end;
+1

... , /frame/datamodule ... ...

Form1.ActionList1.State: = asSuspended;

DataModule1.ActionList1.State: = asNormal;

0

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


All Articles