Problems with TGTextEdit

Hi all,

I have some problems with the TGTextEdit Widget. I think I am just using it the wrong way, but I did not find an explanation neither in the documentation nor among the tutorials.

Following Code does not work as I would suppose it to do, I cannot edit the textbox and it does not showing the teststring either. I am using Root 4.05, for several reasons I cannot update to a higher version.

[code]
#include <TGClient.h>
#include <RQ_OBJECT.h>
#include <TGString.h>
#include <TGTextEdit.h>

class testwindow {
RQ_OBJECT(“testwindow”)

public:
testwindow( const TGWindow* p );

private:
TGMainFrame* fMain;
TGTextEdit* fTextedit;
};

testwindow::testwindow( const TGWindow* p ) {
fMain = new TGMainFrame(p,10,10,kMainFrame | kVerticalFrame);
fMain->SetLayoutBroken(kTRUE);

fTextedit = new TGTextEdit(fMain, 190, 40, “0” );
fTextedit->MoveResize( 50, 50, 200, 30 );
TGText* test = new TGText(“Just a test”);
fTextedit->SetText(test);
fTextedit->Update();

fMain->SetWindowName(“TGTextEdit Tester”);
fMain->MapSubwindows();
fMain->Resize( fMain->GetDefaultSize() );
fMain->MapWindow();
fMain->Resize(400,400);
};

void
testwin(){
new testwindow( gClient->GetRoot() );
}[/code]

Thanks in advance
Oliver
testwin.cpp (913 Bytes)

Ok, I think I found my mistake…

Adding

TGLayoutHints* fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1);
fMain->AddFrame(fTextEdit, fL1);

solves the problem… I just forgot it…
sorry for wasting your time with such an obvious mistake…

Hi Oliver,

Yes, that was the error - your second post arrived at the moment I was writing my answer.

Cheers, Ilka