Is it possible to set arbitrary step size in TGNumberEntry? For example 5 in case of an entry containing ints? I know I can increase the number myself when the buttons are clicked, but then increasing it again sends a signal and it is easy to get into an infinite loop.
I was reacting to the Textchanged() signal. If one changes text on this signal, it goes into infinite loop I assume I will have to connect separately to the signal from the buttons.
Well, that was just a quick test when I could not find any step setting for the control. I more or less expected the behaviour.
Btw. it would be nice to have a control being a mix between TGNumberEntry and TGList - a TGNumberEntry just going through the element of list, whatever they are. I understand that would be a very low priority feature request
I think I don’t see an elegant way of doing what I want to do. Basically, I want TGNumberEntry to react differently when buttons are pressed and when the number is filled from the keyboard. However, the TGNumberEntry buttons do not send any signals…
So is there any way to tell, what type of interaction user had with the TGNumberEntry? ValueSet() signal does not seem to carry that information.
Well, it does not work for the buttons - no signal. I found on this forum, that they are not really TGButtons but TGRapidFireButton (or something like that) that do not emit signal.
Anyway, I attach modified tutorial example with connection made directly to the button. numberEntry.C (2.84 KB)
OK, then [quote=“LeWhoo”]Well, it does not work for the buttons - no signal. I found on this forum, that they are not really TGButtons but TGRapidFireButton (or something like that) that do not emit signal. [/quote]You’re right… Anyway, you can still connect to the TGNumberEntry and the TGTextEntry signals, like for example:
ReturnPressed() still causes ValueSet() to be send later, so I need to set some flag in ReturnPressed() to know in later ValueSet that this is the case of return pressed not the button clicking A little bit dirty, but if nothing else works.
Anyway, I am trying to use it from pyROOT (which makes, at this stage, this forum not fitted for this post) where I have to bind gTQSender to some object before using it. Binding to TGButton or TGNumberEntry makes of course no sense, because it imposes inheritance. I try to bind to TObject, but it also seems to destroy inheritance. I wonder if there is a way I could do this.
Btw. we have functions returning TGButton * which are actually not real TGButtons. Isn’t it a bug?
It seems that ReturnPressed() is emitted after ValueSet(). So I am afraid none of the proposed methods will work. The script will always go through ValueSet(), which does not know is there was also ReturnPressed() or not…
It worked, thanks! However it took me a while to notice that you have changed from “ValueSet” to “ValueChanged”. Still, the whole thing, together with the buttons not emitting a signal issue, calls for a documentation update someday.
I think making buttons emit the signal is the most straightforward thing. However, I am not sure if it can be done without breaking this “continuous increase” of number feature.
I suppose that’s the reason why we have this fNumber->SetButtonToNum(kFALSE); and ValueChanged(Long_t) signal. Otherwise the value would continuously change while keeping one of the buttons down, and it doesn’t make much sense to get notified only of a button state change…