TIDEMenuItem.Visible property not working
Original Reporter info from Mantis: CCRDude @ccrdude
-
Reporter name:
Original Reporter info from Mantis: CCRDude @ccrdude
- Reporter name:
Description:
Given is a Lazarus IDE extension package that adds menus to the main menu, e.g. root menu items, that should be hidden based on user settings.
(In my case, it adds menus Git, Mercurial, Subversion and Bazaar. They'll get added only if the associated VCS is installed on the system. The user can hide them through settings. To save screen estate, it makes sense to set Visible := false and not just Enabled := false on the main menu).
Updated the Visible property during runtime of the Lazarus IDE has no effect; a menu item will stay visible (the Enabled property works on the other hand).
This was confirmed on the Lazarus forums:
http://forum.lazarus.freepascal.org/index.php/topic,37086.0.html
I tracked the issue down to MenuIntf.pas. In TIDEMenuItem.SetVisible, the visibility is correctly set. From there, Section.UpdateVisibleCommandCount is called, and that calls procedure TIDEMenuSection.UpdateContainer, where Item.Visible is set to the sections aSection.RealVisible, ignoring/overriding the actual items visible state.
Reproduced on Win32 and Darwin.
Steps to reproduce:
I have attached a simple test IDE package that shows two IDE main menu items "HideMe" and "ShowOther".
As you will notice, "HideMe" (which sets the TIDEMenuItems Visible to false) has no effect.
If I exit TIDEMenuItem.SetVisible after the RealizeVisible call it's fixed (but side effects may occur, since the following code will have some kind of relevance).
If I remove the Item.Visible := aVisible line from TIDEMenuSection.UpdateContainer, it's fixed (but side effects may occur, there might be a reason why it's there).
Mantis conversion info:
- Mantis ID: 31970
- Version: 1.9 (SVN)
- Fixed in revision: 55259 (#014156ee)