Changing SpinControl value without calling onValueChange()

Started by GetterSetter, 05 April 2024, 17:55:07

GetterSetter

Hello, I want to change SpinControl value without calling onValueChange(), is it possible?
Let me describe what I intend to do and possibly you will give some idea how to implement this.
I have 2 SpinControl widgets (the width and the height of the picture) which are linked/bound (idk which word is more correct here), so changing one should affect another, e.g. if I double height, the width should also be doubled. Let's call the function which is responsible for that BalanceRatio():
//Briefly
BalanceRatio()
{
SpindleControl2->setValue(BalancedValue);
}

When I call it inside onValueChange() it creates a recursion and it's quite logical.
Then I've made the next trick (looks ugly but it actually helped):
SpindleControl1->onValueChange([](){
//Some code here
SpindleControl1->setFocused(0);
});

SpindleControl1->onUnfocus(BalanceRatio);
And it worked pretty nice until I noticed that if I press the arrow continuously, onUnfocus will be never called.
And the question is: how to set the new value without calling onValueChange() to avoid the recursion?
P.S. I'm sorry if there are some grammar mistakes but I feel really fatigued and have neither time nor the desire to use the translator to check my writing   :-\ .

texus

You can temporarily disable the onValueChange signal:
Code (cpp) Select
SpindleControl2->onValueChange.setEnabled(false);
SpindleControl2->setValue(BalancedValue);
SpindleControl2->onValueChange.setEnabled(true);