Finding x,y of mouse click in TRootEmbeddedCanvas

Hi,
I’m trying to add to a gui the ability to find where in a TRootEmbeddedCanvas I click the mouse. I’m having problems getting the click part to work. What I tired was:

fEcanvas = new TRootEmbeddedCanvas(“Ecanvas”,hframe1,500,500);
fEcanvas->Connect(“Clicked()”,“VAEventDisplay”,this,“SelectPixel()”);

This compiled and linked fine but when run I get:

Error in : signal TRootEmbeddedCanvas::Clicked() does not exist

and when I click in the canvas nothing happens(obviously). All the SelectPixel method is supposed to do at this point is print out a message that it got called. That apprently never happens.

Any ideas?

Thanks,
Glenn

Hi Glenn,

The class TRootEmbeddedCanves has no signal method Clicked(). To get what you need, you can use the signal method ProcessedEvent(Int_t,Int_t,Int_t,TObject*) of TCanvas, i.e.

fEcanvas->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "VAEventDisplay", this, "SelectPixel(Int_t,Int_t,Int_t,TObject*)");The 2nd and 3rd parameters will pass x,y coordinates in pixels to your slot method: [code]void VAEventDisplay::SelectPixel(Int_t event, Int_t x, Int_t y, TObject *sel)
{
// Handle mouse click events in the embedded canvas.

if (event == kButton1Down)
printf(“event = %d, x = %d, y = %d, obj = %s::%s\n”, event, x, y,
sel->IsA()->GetName(), sel->GetName());
}
[/code]The macro $ROOTSYS/tutorials/guitest.C contains similar example.

Cheers, Ilka

Thank you, that works really well.

Glenn