unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, System.Actions,
Vcl.ActnList,
Vcl.Menus;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
ActionList1: TActionList;
actTest: TAction;
PopupMenu1: TPopupMenu;
MenuItem1: TMenuItem;
procedure actTestExecute(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.actTestExecute(Sender: TObject);
begin
// gibt es die Möglichkeit, herauszufinden ob der Execute via ShortCut oder MenuItem erfolgt?
// actTest.ActionComponent ist in beiden Fällen gesetzt
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ActionList1 := TActionList.Create(Self);
ActionList1.
Name := '
ActionList1';
actTest := TAction.Create(Self);
actTest.ShortCut := ShortCut(Ord('
T'), [ssCtrl]);
{Strg + T}
actTest.ActionList := ActionList1;
actTest.OnExecute := actTestExecute;
actTest.Caption := '
Test';
actTest.
Name := '
actTest';
PopupMenu1 := TPopupMenu.Create(Self);
PopupMenu1.
Name := '
PopupMenu1';
MenuItem1 := TMenuItem.Create(Self);
MenuItem1.
Name := '
MenuItem1';
MenuItem1.Action := actTest;
PopupMenu1.Items.Add(MenuItem1);
Self.PopupMenu := PopupMenu1;
end;
end.