Для себя я сделал такой алгоритм:
- Код: Выделить всё
type THackAction = class(TCustomAction) end;
function IsActionShortCut(Action: TBasicAction; Sh: TShortCut): boolean;
var ac: THackAction;
begin
ac:= THackAction(Action);
result:= assigned(ac) and (ac is TCustomAction) and (
(ac.ShortCut = Sh) or
(Assigned(ac.SecondaryShortCuts) and
(ac.SecondaryShortCuts.IndexOfShortCut(Sh) >= 0)) and
THackAction(ac).HandleShortCut );
end;
procedure TForm1.FormShortCut(var Msg: TLMKey; var Handled: Boolean);
var Ctl: TControl;
pm : TPopupMenu;
Sh : TShortCut;
begin
Handled := false;
Sh:= KeyToShortCut(Msg.CharCode, MsgKeyDataToShiftState(Msg.KeyData));
if Sh = scNone then exit;
Handled := true;
if Assigned(Menu) and Menu.IsShortCut(Msg) then exit;
Ctl:= Screen.ActiveControl;
while assigned(Ctl) do begin
pm:= Ctl.PopupMenu;
if assigned(pm) and pm.IsShortcut(Msg) then exit;
if IsActionShortCut(Ctl.Action, Sh) then exit;
Ctl:= Ctl.Parent;
end;
Handled := false;
end;