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);
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.
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.
"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,
[/code]The macro $ROOTSYS/tutorials/guitest.C contains similar example.
Thank you, that works really well.