FMXTPopupMenu (Object Pascal)

From Appmethod Code Examples
Jump to: navigation, search


This example shows how to display a TPopupMenu component in the upper left corner of a TButton component, when left-clicking the button.

To test this example, create a FireMonkey Desktop Application - Object Pascal > HD FireMonkey Application, and add the following objects on the form:

Add the following code for the OnClick event of the TButton component.


procedure TForm1.Button1Click(Sender: TObject);
  FP: TPointF;
  //Initialize the coordinates to the origin of the button control.
  FP.X := 0;
  FP.Y := 0;
  //Transposes the coordinates in the context of the form.
  FP := Button1.LocalToAbsolute(FP);
  //Transposes the coordinates in the context of the screen.
  FP := ClientToScreen(FP);
  //Display the popup menu at the computed coordinates.
  PopupMenu1.Popup(FP.X, FP.Y);


See Also