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.
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,...)
The base class for composite widgets (menu bars, list boxes, etc.).
A composite frame with a border and a title.
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
TGNumberEntry is a number entry input widget with up/down buttons.
Yield an action as soon as it is clicked.
ROOT GUI Window base class.