Deleting drawn TLatex object from pad using script

Dear all,

I would like to delete a drawn TLatex object from a pad using a script. Using the GUI it is easily done by right click on the text and choosing the function delete. I have not found the function delete in the function members of the TLatex Class. I think the reason is, that the function DrawLatex() creates a copy of the TLatex object and draws the copy.
Can anyone tell me how to delete the displayed text based on function I can call in a script without clearing the whole canvas? Do I have to access the copy (I do not know how)?

The question is similar to the thread root.cern.ch/phpBB2/viewtopic.ph … tex+delete
Its solution is hard to understand since Draw is not a member function of TLatex.

Best regards
Maciek

The most simple way is:

root [0] TCanvas C
root [1] TLatex t(.5,.5,"abcd")
root [2] t.Draw()
root [3] t.Delete()

Ie: you keep the pointer to the text you want to delete.
DrawLatex returns the pointer to the drawn text. To get the pointer simply do

T = DrawLatex(...)

Where T is a TLatex*

Note that LaTex inherits from TText and gets the Draw function that way.

Thak you, this works perfectly.

Maciek