TActionMainMenuBar have a bug with painting root elemetnts without child items.
Using Delphi XE2 / w7-32bit**
how to reproduce:
build menu with TActionMainMenuBar, add some actions to it:
file | options | help
- New
- Open
- Save
-Exit
assign to all actions one empty method
procedure TfrmMain.ActionExecute(Sender: TObject);
begin
//
end;
now run application and try to click on options or help element.
now click on form, but the menu element is still pressed!
any workarounds exists?
upd: look at screenshot, menu element is down, but mouse cursor not on menu, and autocheck is false, and checked is false too.
here is not any colormap on the form, and manager style is platform default
here is my workaround:
create custom class like this:
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;
now in you TActionMainMenuBar.OnGetControlClass add this simple code, and set to 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;
well, now all root items with -100 tag, works as we wish
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With