Re: synchronizing two spin buttons



At a guess.. i'd imagine it's because when the second callback happens
it sets the spin button to the same value, which does not trigger a
value_changed signal to be emitted.

I remember being confused by this in some other widget. Possibly
ComboBoxText, when you click... and then rechoose the same thing....

Rob.

On 07/02/06, Amadeus W. M. <amadeus84 cablespeed com> wrote:
> I have two spin buttons OneSpin and TwoSpin. I need to keep them
> synchronized so that at all times their values add up to 100.
>
> So I have callbacks:
>
> void window1::on_OneSpin_value_changed()
> {
>     std::cerr << "One's callback." << std::endl;
>     TwoSpin->set_value(100-OneSpin->get_value());
> }
>
> void window1::on_TwoSpin_value_changed()
> {
>     std::cerr << "Two's callback." << std::endl;
>     OneSpin->set_value(100-TwoSpin->get_value());
> }
>
> This does work, but I would have expected an infinite loop.
>
> Since a change of value in either button triggers the appropriate
> callback, and since each callback sets the value of the other button, why
> does this not produce an infinite loop?
>
> If it had produced a loop, I'd know how to break it: just make each
> set_value() conditional upon whether or not the new value is different
> from the old value.
>
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]