Board index » delphi » Action shortcut does not fire when in a frame in a frame on the form

Action shortcut does not fire when in a frame in a frame on the form

Hi,

I have an ActionList on a frame which is on an other frame,
which in its turn is placed on a form (at runtime). If I assign a
shortcut to this a action in the list it will not fire, although the
hint is indicating the shortcut allright.

If you have an actionlist on a frame which is directly placed
(again at runtime) on a form this problem does not arise.

Now I have understood from previous posts this has to do
with the way the frame rigisteres its actionslist at the form.
Quite obviously it does not register an actionlist which is
burried two levels deep (frame on frame on form).

Can you manually register this actionlist in order to get
the shortcuts working?

Ruud.

 

Re:Action shortcut does not fire when in a frame in a frame on the form


Quote
Ruud Vlaming wrote:
> If you have an actionlist on a frame which is directly placed
> (again at runtime) on a form this problem does not arise.

Also the problem is easily solved when the framed are
placed at designtime. The only thing you have to do is
to alter one property of the actionlist (the tag for example)
on the frame embedded in the frame embedded in the form.
Somehow this forces the actionlist to register itself, probably
because an in inherited component is created that way.

However, this is not possible when placing the
frame at runtime on the form.

This just as extra information.

Ruud

Re:Action shortcut does not fire when in a frame in a frame on the form


Quote
Ruud Vlaming wrote:
> Can you manually register this actionlist in order to get
> the shortcuts working?

Sorry to have bothered anyone, the solution seems quite simple.
You can register actions yourself by making use of the protected
variable FActionLists.

In the form define a new procedure as follows:

  procedure TMyForm.AddToActionLists(
       const ActionList: TCustomActionList);
  begin
  if FActionLists=nil then FActionLists:=TList.Create;
  FActionLists.Add(ActionList);
  end;

Then register it like

  procedure TMyForm.FormActionRegister;
  begin
  AddToActionLists(Frame1.FrameB.ActionList);
  AddToActionLists(Frame2.FrameB.ActionList);
  end;

Hope this if of help to someone else.
Comments welcome,

Ruud.

Other Threads