Toggle button listener gets wrong button!


#1

Hi, I have a simple audio app that ‘loads’ plays’ and has a ‘loop’ button toggle.
If I add a listener to the loop toggle it always calls the listener with the play button pointer. Why is this? It is no where near the button so it can’t be confused with overlapping mouse areas.
It does seem to matter what order I add them.
This is in the MainComponent constructor:
{

	addAndMakeVisible(loadButton);
	addAndMakeVisible(playButton);
	addAndMakeVisible(loopButton);
	addAndMakeVisible(wave);
	playButton.setEnabled(false);

	loadButton.addListener(this);
	playButton.addListener(this);
	loopButton.addListener(this);

}
    	TextButton loadButton{ "Load WAV file" }, playButton{ "Play" };
    	ToggleButton loopButton{ "Loop" };

*edit
Even if I don’t add the play button it still get referenced in the listener!


#2

What does your buttonClicked() callback look like?


#3

Never mind. It was just a rookie mistake. I’ve had some sleep now. :slight_smile:
Thanks anyway.
BTW How do I delete a post on here?