This macro gives an example of how to create a number entry and how to update a label according to the changed value of this number entry.
To run it do either:
private:
public:
virtual ~MyMainFrame();
void DoSetlabel();
};
{
fExit =
new TGTextButton(fHor1,
"&Exit",
"gApplication->Terminate(0)");
0, 99999);
fNumber->Connect("ValueSet(Long_t)", "MyMainFrame", this, "DoSetlabel()");
(fNumber->GetNumberEntry())->Connect("ReturnPressed()", "MyMainFrame", this,
"DoSetlabel()");
fLabel =
new TGLabel(fGframe,
"No input.");
5, 5, 5, 5));
SetWindowName("Number Entry");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
}
void MyMainFrame::DoSetlabel()
{
fLabel->SetText(
Form(
"%ld",fNumber->GetNumberEntry()->GetIntNumber()));
fGframe->Layout();
}
{
new MyMainFrame(
gClient->GetRoot(), 50, 50);
}
#define ClassDef(name, id)
char * Form(const char *fmt,...)
- Author
- Ilka Antcheva 1/12/2006
Definition in file numberEntry.C.