You cannot control how popup shows up, the position and size depend on the amount of the popup items.
Except you write your own custom-made popup component. Or creating a form that behaves like a popup. Try my custompopup.zip:
unit unit2;
{$mode objfpc}{$H+}
interface
uses
Forms, Controls, StdCtrls;
type
{ TfrmPopup }
TfrmPopup = class(TForm)
ListBox1: TListBox;
procedure ListBox1DblClick(Sender: TObject);
procedure ListBox1KeyPress(Sender: TObject; var Key: char);
public
Selected: Integer; // -1 means cancelled
end;
var
frmPopup: TfrmPopup;
implementation
{$R *.lfm}
{ TfrmPopup }
procedure TfrmPopup.ListBox1KeyPress(Sender: TObject; var Key: char);
begin
case Key of
#27: begin
Selected := -1;
Close;
end;
#13: begin
Selected := ListBox1.ItemIndex;
Close;
end;
end;
end;
procedure TfrmPopup.ListBox1DblClick(Sender: TObject);
const
C: Char = #13;
begin
ListBox1KeyPress(Self, C);
end;
end.
I tested the code on Ubuntu Mate. The appearance may be different on Windows.
=== edit ===Actually, we can control the X, Y positions of a TPopupMenu to show up. But the problem is, if the list contains a lot of items, the position will be changed automatically to able to show on your screen. Here are the calculations:
Popup.Top := Button1.Top + Button1.Height + Form1.Top - Popup.Height;
Popup.Left := Button1.Left + Form1.Left;