View Issue Details

IDProjectCategoryView StatusLast Update
0012776LazarusLCLpublic2018-03-20 18:03
ReporterMichael Van Canneyt Assigned ToPaul Ishenin  
Status closedResolutionfixed 
Product Version0.9.27 (SVN) 
Target Version1.0.0Fixed in Version0.9.27 (SVN) 
Summary0012776: Actions not updated if only in menu
DescriptionWhen an action is attached only to a menu item, it is not updated
when the menu item is made visible. Actions that are attached to menu items are not updated when a menu is popped up.
Steps To ReproduceCompile and run attached sample program.
Note that the checkbox is not checked, and hence the action should be disabled.
- Click 'Test' menu: 'Test action' menu item should be enabled.
- Click it.
  The action is NOT executed, because update handler is executed first
  and it disables the action.
- Click 'test' menu again: 'Test action' menu item is now disabled.
The 'OnUpdate' handler should be executed whenever the associated menu item becomes visible.
TagsNo tags attached.
Fixed in Revision18006
Attached Files


related to 0033465 new Menu items don't trigger action updates 


2008-12-09 21:10 (231,131 bytes)

Vincent Snijders

2008-12-09 21:14

manager   ~0023738

Last edited: 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).

Leslie Kaye

2008-12-15 13:49

reporter   ~0023844

Last edited: 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
Note: missing feature...
TPopupMenu should have a published a property override from TMenu:
    property OnChange;

Klaus Reimer

2008-12-31 15:56

reporter   ~0024078

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);

procedure TForm1.InstallActionUpdateFix(MenuItem: TMenuItem);
  i: Integer;
  if (MenuItem.Count > 0) and (not Assigned(MenuItem.OnClick)) then
    MenuItem.OnClick := @FixActionUpdate;
    for i := 0 to MenuItem.Count - 1 do

procedure TForm1.FixActionUpdate(Sender: TObject);
  i: Integer;
  MenuItem: TMenuItem;
  for i := 0 to TMenuItem(Sender).Count - 1 do
    MenuItem := TMenuItem(Sender).Items[i];
    if Assigned(MenuItem.Action) and Assigned(MenuItem.Action.OnUpdate) then

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.

Paul Ishenin

2009-01-01 11:11

manager   ~0024079

Please test and close if ok.

Issue History

Date Modified Username Field Change
2008-12-09 21:10 Michael Van Canneyt New Issue
2008-12-09 21:10 Michael Van Canneyt File Added:
2008-12-09 21:10 Michael Van Canneyt LazTarget => -
2008-12-09 21:10 Michael Van Canneyt Widgetset => GTK
2008-12-09 21:13 Vincent Snijders LazTarget - => 1.0
2008-12-09 21:13 Vincent Snijders Status new => acknowledged
2008-12-09 21:13 Vincent Snijders Target Version 0.9.28 => 1.0.0
2008-12-09 21:14 Vincent Snijders Note Added: 0023738
2008-12-09 21:14 Vincent Snijders Note Edited: 0023738
2008-12-15 13:49 Leslie Kaye Note Added: 0023844
2008-12-18 09:53 Leslie Kaye Note Edited: 0023844
2008-12-18 09:54 Leslie Kaye Note Edited: 0023844
2008-12-31 15:56 Klaus Reimer Note Added: 0024078
2009-01-01 11:11 Paul Ishenin Fixed in Revision => 18006
2009-01-01 11:11 Paul Ishenin Status acknowledged => resolved
2009-01-01 11:11 Paul Ishenin Fixed in Version => 0.9.27 (SVN)
2009-01-01 11:11 Paul Ishenin Resolution open => fixed
2009-01-01 11:11 Paul Ishenin Assigned To => Paul Ishenin
2009-01-01 11:11 Paul Ishenin Note Added: 0024079
2009-06-13 12:08 Marc Weustink Status resolved => closed
2018-03-20 18:03 Stephano Relationship added related to 0033465