Deleting text from canvas

Hello,

How can I remove a text from a canvas?
I want to replace the text between calls c1->Print().

Deleting the text object itself does not work: the following
code shows the canvas with the text although there is
no text object.

Version 4.04/02

Thanks,
Sebastian

TCanvas *c1 = new TCanvas("c1", "c1",10,20,1024,768);
TLatex *myLatex;
myLatex = new TLatex;
myLatex->SetNDC();
myLatex->DrawLatex(0.2,0.3,"text");
delete myLatex;
c1->Modified();
c1->Update();

Instead of:

delete myLatex; c1->Modified(); c1->Update();
do

c1->Modified(); c1->Update(); delete myLatex;

Rene

That does not change it here. Tried other orders and also
c1->ForceUpdate() but still the text is there.

Please to make progress send the shortest possible running script reproducing the problem.

Rene

The code is in the first posting. Put it in a file test.C, enclosed
in curly braces, and call at ROOT prompt: .x test.C

Thanks,

Sebastian

Look at the specs of Tlatex::DrawLatex.
It creates and retuurns a copy of the input object.
In your case, use Draw instead of DrawLatex.

Rene