how to lock two sliders or spin buttons



I want to mimic the behavior of the knobs in volume control applications.
Usually there is a knob for the left speaker and another for the right
one, and a lock check button. If the lock is on, sliding one of the knobs
moves the other one simultaneously.

I have two spin buttons rather than knobs, DxSpin and DySpin, and
callbacks on_DxSpin_changed() and on_DySpin_changed(), connected each to
the corresponding changed signal. 

>From within either callback, I read the value and set the other spin
button to the exact same value:

on_DxSpin_changed()
{
  if(Lock->get_active())
    DySpin->set_value(DxSpin->get_value());
}

and similarly for DySpin. This naive approach produces an infinite loop,
obviously: each time the Dx button changes the value of Dy, Dy will also
change the value of Dy, and so on.

How do I do this? 






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