Question on TGTextEntry

Dear ROOT friends

I am wondering what is the best way to update text in a TGTextEntry.
Let’s say I have a TGTextEntry * fTE, which contains a TGTextBuffer * fTB. According to $ROOTSYS/tutorials/gui/guitest.C, the way to update the text would be something like

   sprintf(buf, "%f", var);
   fTB->Clear();
   fTB->AddText(0, buf);
   fTE->SetCursorPosition(fTE->GetCursorPosition());
   fTE->Deselect();
   gClient->NeedRedraw(fTE);

Now, in my own code I realize that I’ve been happily using the much simpler

   sprintf(buf, "%f", var);
   fTE->SetText(buf);

…which for my purpose works just as well! Can somebody enlighten me what the difference between the two approaches is, and if the use of the simple SetText is discouraged for some reason? Is it less portable than the complicated sequence given in guitest.C?

Many thanks in advance,

Thomas

Hi,
the code of ROOT GUI classes was originated from xclass95 lib,
but then it was very much developed/extended and modified.
This is the case of TGTextEntry class.
The first your case is “inherited” one, the second is “developed” one.
So, both are valid, “identical”, but the second one is simpler.

Regards. Valeriy