GUI: connecting method to TGNumberEntry up/down buttons


I’m working on a GUI with a canvas and a number entry field that shows the position of a TLine on the canvas. Now, I would like for the line to move instantaneously when you change the number entry value by clicking the up/down buttons.

Usually, e.g. for text buttons, you do:

fButton->Connect("Clicked()", "receiver_class", this, "MoveTheLine()");

I tried that and “MoveTheLine()” works as supposed to.

So I tried the same thing for the buttons from the number entry which I get by:

fButtonUp = new TGButton(fNumEntry->GetButtonUp());
fButtonDown = new TGButton(fNumEntry->GetButtonDown());

When you click the buttons, the number in the entry field changes just fine but nothing else is happening.

Any ideas on how to make this work?



The buttons used in TGNumbeEntry are a special class (TGRepeatFireButton) used to repeat clicks when keeping the mouse pressed on it, and hence they don’t emit any signal. So you should try to use one of the the TGNumberEntry signals, e.g.:fNumber->Connect("ValueSet(Long_t)", "receiver_class", this, "MoveTheLine(Long_t)"); fNumber->Connect("ValueChanged(Long_t)", "receiver_class", this, "MoveTheLine(Long_t)");
See for example the [color=#0000FF]$ROOTSYS/tutorials/gui/numberEntry.C[/color] tutorial

Cheers, Bertrand.

Thanks, worked well!