synchronizing two spin buttons
- From: "Amadeus W. M." <amadeus84 cablespeed com>
- To: gtkmm-list gnome org
- Subject: synchronizing two spin buttons
- Date: Mon, 06 Feb 2006 20:27:44 -0500
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]