TGTextView : there seems to be an empty line at the top

Dear all,
Dear Bertrand,

Looking at the TGTextView, it seems that there is always a blank line at the beginning. Here is an example code :

TGMainFrame *frame = new TGMainFrame(gClient->GetRoot(), 700, 300);
TGTextView *view = new TGTextView(frame, 700, 80)
frame->AddFrame(view, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2))
frame->MapSubwindows();
frame->MapWindow();
view->AddLine("adsf")

If you execute it you should see a window with a text area and the text “adsf” in it. But the text is not at the top of the text area, it is at line 2.

Why is that ? Do you see the same ?
How to have the text start at the first line ?

Thanks in advance for your advices !
Barth

Hi Barth,

Well, AddLine() adds a new line (but I agree it looks weird in this case…) You can use LoadBuffer() first, and then AddLine(). Like this:

view->LoadBuffer("adsf"); view->AddLine("ghjk");
Or prepare your full text in a TString (or any buffer) and only use LoadBuffer()…

Cheers, Bertrand.

Hi,

Ok, I got it. I thought it would add a new line at the end of the string not before. I will try your solution.

Thanks !
Barth