Delphi Firemonkey OSX how to show properly popup menu on button click?

  

I have a couple of buttons, which all have to show various popup menus when clicked. I use the following code in the onClick event of the buttons:

procedure TForm1.btnExportClick(Sender: TObject);
var
pt:TPointF;
begin
pt.X:=0;
pt.Y:=btnExport.Height;
pt:=btnExport.LocalToAbsolute(pt);
pt:=ClientToScreen(pt);
mnuExport.Popup(pt.X,pt.y);
end;

When I click a button and release the mouse, the onClick event is triggered, the button turns blue and the popup menu appears.

When I then click another button, without releasing the mouse (so it should not trigger a onclick event yet), the first popup menu vanish, but the popup menu of the other button appear and the onClick event is triggered (I see this in debugger).

When I first close the popup menu by clicking somewhere else, then the other button also work as expected, but as long a popup menu is open, the buttons onClick event is triggered even I do not release the mouse button yet.

There is definitely something wrong with my code or way to do it.

Note: It only happen when running it on Mac OSX, not on Windows using FireMonkey.

How to do it properly?

Comments are closed.