Cross hair positions on Canvas

ROOTers,
I would like to extract the mouse position when it is on my canvas when plotting some neat graphs. Could somebody please advise how I could do that?

Thanks a lot,
Cristian

See: TCanvas::GetEventX(); TCanvas::GetEventY(); TCanvas::GetEvent() methods.TCanvas::GetSelectedX() TCanvas::GetSelectedY() can be useful also.

[quote=“fine”]See: TCanvas::GetEventX(); TCanvas::GetEventY(); TCanvas::GetEvent() methods.TCanvas::GetSelectedX() TCanvas::GetSelectedY() can be useful also.[/quote]

Hi
Yes I notice the private members from the TCanvas class (int fEventX, fEventY) and I tried GetEventX and GetEventY but I kept getting the same position (1,0). What do these functions return? Do they return values based on the current scale of the canvas where my TGraph was drawn?

I will try tomorrow the other two methods you suggested. Thxs a lot for replying,

Cristian

Hi Christian,

You can also take a look at the DynamicSlice.C tutorial

Cheers,
Bertrand.

A fine and simple example can be found at tutorials/hist/exec1.C

Cristian