Notes |
(0023738)
Vincent Snijders (manager)
2008-12-09 21:14
edited on: 2008-12-09 21:14
|
0.9.28, if a patch is provided or this is a regression (= it worked correctly in earlier Lazarus versions).
|
|
(0023844)
Leslie Kaye (reporter)
2008-12-15 13:49
edited on: 2008-12-18 09:54
|
The problem is caused by a missing call to TMainMenu.FItems.InitiateActions
I suggest the resolution is to place the following at the start of TMenuItem.Click;
****
if IsInMenuBar then
InitiateActions;
****
Note: missing feature...
TPopupMenu should have a published a property override from TMenu:
property OnChange;
|
|
(0024078)
Klaus Reimer (reporter)
2008-12-31 15:56
|
I stumbled over the same problem (In 0.9.26 release and daily snapshot 20081231) . Actions which are connected to buttons are correctly updated by a timer, actions connected to a popup menu are updated when the popup menu opens but actions which are only connected to a main menu item are only updated when the action is executed. This is pretty useless. I have a "CloseAction" which must be disabled when nothing is there to close. The result is, the user can click "Close" which does nothing but disabling the Close Action.
My workaround is putting this code into my form:
procedure TForm1.FormCreate(Sender: TObject);
begin
InstallActionUpdateFix(MainMenu1.Items);
end;
procedure TForm1.InstallActionUpdateFix(MenuItem: TMenuItem);
var
i: Integer;
begin
if (MenuItem.Count > 0) and (not Assigned(MenuItem.OnClick)) then
begin
MenuItem.OnClick := @FixActionUpdate;
for i := 0 to MenuItem.Count - 1 do
InstallActionUpdateFix(MenuItem.Items[i]);
end;
end;
procedure TForm1.FixActionUpdate(Sender: TObject);
var
i: Integer;
MenuItem: TMenuItem;
begin
for i := 0 to TMenuItem(Sender).Count - 1 do
begin
MenuItem := TMenuItem(Sender).Items[i];
if Assigned(MenuItem.Action) and Assigned(MenuItem.Action.OnUpdate) then
begin
MenuItem.Action.OnUpdate(MenuItem.Action);
end;
end;
end;
This code does the following: When the form is created then a special OnClick handler is installed into ALL main menu items which have sub menu items. This special OnClick handler calls the OnUpdate method of all actions connected to sub menu items of the clicked menu item.
Works great but I hope that a similiar functionality will be implemented in LCL some day because without it the ActionList is quite useless if most actions are only referenced in a main menu. |
|
(0024079)
Paul Ishenin (manager)
2009-01-01 11:11
|
Please test and close if ok. |
|