[Lazarus] TMenu calls OnClick twice per click
kapibara
kapibara.pas at aol.com
Fri Sep 21 23:03:05 CEST 2018
Hi Guys!
Under Linux GTK2, clicking a MenuItem with RadioButton calls OnClick twice.
Calling MenuItem.Click by code at runtime doesn't seem to change the
selected menuitem in the menu?
Under Windows I dont see the RadioButton in the menu, and OnClick is
called only once.
See demo.
procedure TForm1.btnAddMenuItemClick(Sender: TObject);
var
s:string;
aTargetMenu, aMenuItem: TMenuItem;
begin
aTargetMenu:= MainMenu.Items.Find('&Menu');
s:='MenuItem ' +IntToStr(aTargetMenu.Count +1);
s:=InputBox('Menu name','Enter Menu Name:', s);
aMenuItem:=TMenuItem.Create(MainMenu);
aMenuItem.OnClick:=@MenuClickHandler;
aMenuItem.RadioItem:=True;
aMenuItem.Caption:=s;
aTargetMenu.Add(aMenuItem);
aMenuItem.Click; //Doesnt change selected menuitem with RadioButton!
end;
procedure TForm1.MenuClickHandler(Sender: TObject);
begin
ShowMessage('Clicked!');
end;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AddMenuItem.zip
Type: application/zip
Size: 2280 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180921/324577f3/attachment.zip>
More information about the Lazarus
mailing list