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?
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