Re: Weird RadioButton behaviour
Hi Tadej, On Tue, 3 May 2011 22:25:58 +0200 you wrote: > > Why do you connect to both GtkButton::clicked and > GtkToggleButton::toggled signals? It would probably be better to only > connect to toggled one. The SpinButtons "time out", so clicking back on the already-active RadioButton should re-show it. It seemed from my original tests that the toggled signal was not emitted by this, but I wasn't expecting the clicked signal to be useful for the button being moved away from. For example: The "Current" RadioButton is selected and the user clicks on "Power" - This needs to hide the "Current" spinner and show the "Power" one The "Power" RadioButton is selected and the user clicks it again - The "Power" spinner needs to be shown again if it's timed out With only the toggled signal connected, I don't get the second of these, and I _do_ still have the buggy behaviour with cursor keys. This was where I started from before adding the timeouts. Rather surprisingly (at least it feels counter-intuitive to me), with only the clicked signal connected, it seems to work. I'm not totally happy with relying on a signal being sent when the event it's named for clearly hasn't happened, but if it's the best way to do it I'll cope :) Thanks for your help. Rob ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Weird RadioButton behaviour
Hi. > I have an application on which a group of RadioButtons select the > control mode. The modes that are not "in control" show the current > reading, while the "in control" has a SpinButton. To do this widget > switching I have hooked up to the signal_toggled and signal_clicked of > the RadioButtons and in the handler I check the get_state() value. > > This works fine when I click on the radio buttons with the mouse. The > callback is invoked four times; twice on the old selection with the > get_state returning false, then twice on the new with get_state() true. > I don't know which order the clicked and toggled signals occur but it > doesn't really matter. I am slightly surprised that I get two events on > the old button - I haven't clicked it, after all. I did have similar troubles quite some time ago. IIRC, the problems were caused by the fact that GtkButton::clicked is an action signal that gets emitted quite a lot by GTK+ itself. It's been a while since I last looked at GTK+'s sources, but I think that chain of events/signals that lead to observed behavior is: Clicking with a mouse: GtkToggleButton::button-released -> GtkButton::clicked -> GtkToggleButton::toggled Not sure what would chain for keyboard navigation be, but I'm almost sure that state change is done via GtkButton::clicked signal. > The problem is when I use the cursor keys to change button. Most times > it works the same, but often (and it seems to usually be most times I > move away from a particular button) the two signals sent by the > "leaving" button happen with its get_state() still returning true. > > Presumably this is a race condition of some sort, but why is it so > consistently problematic on keyboard actions and never on mouse? Is > there a better way to do the whole thing? Why do you connect to both GtkButton::clicked and GtkToggleButton::toggled signals? It would probably be better to only connect to toggled one. Hope this helps a bit, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Weird RadioButton behaviour
I have an application on which a group of RadioButtons select the control mode. The modes that are not "in control" show the current reading, while the "in control" has a SpinButton. To do this widget switching I have hooked up to the signal_toggled and signal_clicked of the RadioButtons and in the handler I check the get_state() value. This works fine when I click on the radio buttons with the mouse. The callback is invoked four times; twice on the old selection with the get_state returning false, then twice on the new with get_state() true. I don't know which order the clicked and toggled signals occur but it doesn't really matter. I am slightly surprised that I get two events on the old button - I haven't clicked it, after all. The problem is when I use the cursor keys to change button. Most times it works the same, but often (and it seems to usually be most times I move away from a particular button) the two signals sent by the "leaving" button happen with its get_state() still returning true. Presumably this is a race condition of some sort, but why is it so consistently problematic on keyboard actions and never on mouse? Is there a better way to do the whole thing? Thanks, Rob ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list