This macro gives an example for changing text button labels anytime the Start or Pause buttons are clicked.
To run it do either:
.x buttonChangelabel.C
.x buttonChangelabel.C++
private:
public:
virtual ~MyMainFrame();
void ChangeStartLabel();
void ChangePauseLabel();
};
void MyMainFrame::ChangeStartLabel()
{
if (!start) {
fStart->SetText("&Stop");
} else {
fStart->SetText("&Start");
}
}
void MyMainFrame::ChangePauseLabel()
{
if (!pause) {
fPause->SetText("&Resume");
} else {
fPause->SetText("&Pause");
}
}
{
fStart->Connect("Clicked()", "MyMainFrame", this, "ChangeStartLabel()");
3, 2, 2, 2));
fStart->SetToolTipText("Click to toggle the button label (Start/Stop)");
fPause->Connect("Clicked()", "MyMainFrame", this, "ChangePauseLabel()");
fPause->SetToolTipText("Click to toggle the button label (Pause/Resume)");
3, 2, 2, 2));
fExit =
new TGTextButton(
this,
"&Exit ",
"gApplication->Terminate(0)");
SetWindowName("Change Labels");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
fCframe->Cleanup();
Cleanup();
}
void buttonChangelabel()
{
new MyMainFrame(
gClient->GetRoot(), 350, 80);
}
#define ClassDef(name, id)
- Author
- Ilka Antcheva 1/12/2006
Definition in file buttonChangelabel.C.