Hello,
I have problem with juce::ToggleButton
because I always was sure that onStateChange
is called when toggle state of button is changed. But it is called every mouse enter, exit, down etc.
There is also lambda onClick
, but it is called everytime I click the button, no matter if toggle state was changed or not.
But I am looking for something that would be called only when toggle state is changed
Is there anything like that in juce::ToggleButton
, or in juce::Button
?
For any help great thanks in advance.
Best Regards
2 Likes
onClick
will be called when the toggle state is changed if the second argument to setToggleState()
is set to send notifications. It’s always called just after the listeners are called - if the listeners aren’t called, onClick
won’t be called.
There’s no way to get a callback from a button when it’s toggle state changes but the notification type was set to dontSendNotification
- that’s the whole point of that second argument.
Think I misread your post originally - as you say, onClick
is called regardless of whether or not the state has changed - same for the buttonClicked()
callback for listeners.
You’d have to manually keep track of the button’s state and check if it’s changed in the callbacks so you can act accordingly
OK, thanks for your explanation.