Draw line into TGraph


I have a very simple need, but I still was not able to solve it.

Starting from a TGraph drawn into a pad, I would like to draw a vertical line at the position of the mouse when the mouse button is clicked. I have added a TExec to the canvas and I am able to get the mouse event and also the mouse position, but when I try to draw a line with gPad->Paintline(,), nothing appears.

Could anybody maybe give me a hint how one should do this?



See $ROOTSYS/tutorials/graphics/canvas.C
It shows how to draw the “moving” lines using the TLine class
Try it as follows