views:

78

answers:

2

Having a popup menu attached to several components on a form (buttons, but also things like TCharts), I would like to know which component was right clicked to start the popup menu in the first place.

The Sender parameter of the click method just points to the TMenuItem, its parent to the popup menu (or the parenting menu item).

How do I get the originating component?

+10  A: 

Did you mean PopupMenu1.PopupComponent ?

SimaWB
+1. Or, to be more generic, I'd use this in the menu's OnPopup event: (Sender as TPopupMenu).PopupComponent
Bruce McGee
A: 

As a last resort you can use Mouse.CursorPos in TPopupMenu.OnPopup to find this component on a form. But there is probably a better/easier way.