Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-09

TMenu calls OnClick twice per click

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

kapibara

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.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>

Reply by email