Work on the TActionMainMenuBar draw error where the item does not deselect

TActionMainMenuBar has an error with red root elements without children.

Using Delphi XE2 / w7-32bit **

how to reproduce:
build a menu using TActionMainMenuBar, add some actions to it:

 file  | options | help
 - New
 - Open
 - Save
  -Exit

assign all actions one empty method

procedure TfrmMain.ActionExecute(Sender: TObject); 
begin 
// 
end;

Now launch the application and try clicking on the options or help item.
now click on the form, but the menu item is still clicked!

Are there any workarounds?

upd: look at the screenshot, the menu item is omitted, but the mouse cursor is not in the menu, and autocheck is false, and false is also marked.
enter image description here
there is no color scheme in the form, and the manager style is the default for the platform

+5
2

:
:


type
  TFastThemedButton = class(TThemedMenuButton)
  protected
    procedure DrawBackground(var PaintRect: TRect); override;
end;

...


procedure TFastThemedButton.DrawBackground(var PaintRect: TRect);
const
  MenuStates: array[Boolean {MouseInControl}, Boolean {Selected}] of TThemedMenu =
    ((tmMenuBarItemNormal, tmMenuBarItemPushed), (tmMenuBarItemHot, tmMenuBarItemPushed));
var
  BannerRect: TRect;
  StartCol, EndCol: TColor;
begin
   Canvas.Brush.Color := ActionBar.ColorMap.Color;
   Canvas.Font := ActionBar.Font;
   StyleServices.DrawElement(Canvas.Handle, StyleServices.GetElementDetails(MenuStates[MouseInControl, (State=bsDown)]), PaintRect);
end;

TActionMainMenuBar.OnGetControlClass buggy actionclients tag = -100


procedure TfrmActions.ActionMainMenuBar1GetControlClass(Sender: TCustomActionBar; AnItem: TActionClient; var ControlClass: TCustomActionControlClass);
begin
  if ControlClass.InheritsFrom(TCustomMenuButton) and then
   begin
    if (AnItem.Tag =-100) and (ControlClass = TThemedMenuButton) then
      ControlClass := TFastThemedButton;
   end;
end;

, -100 ,

+1

MainMenuExitMenuLoop MainMenu.RecreateControls . .

0

All Articles