RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TPopupMenu.OnPopup Event

Occurs just before the pop-up menu appears.

Pascal
property OnPopup: TNotifyEvent;
C++
__property TNotifyEvent OnPopup;

Write an OnPopup event handler to take specific action just before the pop-up menu appears. For example, use an OnPopup event handler to set the Checked, Enabled, or Visible property of individual items in the menu so that they are appropriate to the PopupComponent.  

Delphi Examples: 

 

{
The following code enables the Copy item from the pop-up
menu if the edit control has a nonempty selection.
Note: A portion of the edit control text must be highlighted.
}
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
  Copy1.Enabled := Edit1.SelLength > 0;
end;

procedure TForm1.Copy1Click(Sender: TObject);
begin
    ListBox1.Items.Add('"Copy" menu');
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  PopupMenu1.Popup(Left + X, Top + Y);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!