[Lazarus] TMenu calls OnClick twice per click

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] TMenu calls OnClick twice per click

Free Pascal - Lazarus mailing list
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;


--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

AddMenuItem.zip (3K) Download Attachment