Find which pad has been clicked in a TCanvas

Hi,

I have a TCanvas with several TPads and I connected its ProcessedEvent in order to get the Clicked events and take some action. It works well as long as the TPads are empty. But if there is an histo in a tpad, then the “selected” (fourth arg) given by ProcessedEvent is a TFrame instead of a TPad.
I really need a pointer to the tpad which is clicked.
How should I do that ? Is there a way of knowing the TPad which is the parent of the TFrame reference I get ? Or a way of asking the TCanvas which pad is on coordinates x, y ?

Thanks in advance for your help

Barth

PS : here is a bit of code just to express better what is my problem

void TAmoreObjectManager::HandleCanvasClicked(Int_t event, Int_t x, Int_t y, TObject *selected)
{
   switch (event){
   case kButton1Up:
      TCanvas *c = (TCanvas *) gTQSender;
       printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n", c->GetName(),
               event, x, y, selected->IsA()->GetName());
       // this will return the name TFrame when clicking on an histo which is in a TPad
       // but I would like to select the TPad when a click occur, therefore I need a pointer
       // to the TPad
      break;
   }
}

Hi Barth,

You can try this:TPad *pad = c->Pick(x, y, 0);
or to get the currently selected pad:TPad *pad = gROOT->GetSelectedPad();
Cheers,
Bertrand.

[quote=“bellenot”]Hi Barth,

You can try this:TPad *pad = c->Pick(x, y, 0);
[/quote]

Thanks Bertrand, this is exactly what I was looking for !

Cheers,

Barth