How to change textbutton's fill clour in turn when clicked?

Hi everyone,
I want some textbuttons that could change their fill colour in turn when clicked. For exampe,it will show green fill colour when first clicked and it will show the red fill colour when second clicked. Then,it will show green fill colour when third clicked and it will show the red fill colour when fourth clicked. And in turn for the next button clicked. Every button in a child component(DownMiddleModule), these child components are located in OwnedArray:OwnedArray downmiddlemodules;I override the drawButtonBackground function,it seems ok for only one child component operation. it does not work for some buttons at the same time. For example,we first click one button ,so it’s fill colour will become green. Then we move the mouse to another button’s above(NOTE:here we do not click the mouse),but now this button’s fill colour become green.I don’t know why.Do you have the other methods?

void drawButtonBackground(Graphics & g, Button & button, const Colour & backgroundColour, bool isMouseOverButton, bool isButtonDown) override
    	{
    		//auto buttonArea = button.getLocalBounds();
    		//g.setColour(backgroundColour);
    		//g.fillRect(buttonArea);
    		static int c_index = 0;
    		static int on_off=0;
    		auto buttonArea = button.getLocalBounds();
    		//auto edge = 4;
    		//buttonArea.removeFromLeft(edge);
    		//buttonArea.removeFromTop(edge);
    		// shadow
    		if (isButtonDown && (on_off==0))
    		{
    			c_index = 1;
    			on_off = 1;
    		}
    		else if (isButtonDown && (on_off == 1))
    		{
    			c_index = 0;
    			on_off = 0;
    		}
         
    		if (c_index==1)
    		{
    			g.setColour(Colours::green);
    			g.fillRect(buttonArea);
    		}
    		else if(c_index == 0)
    		{
    			g.setColour(backgroundColour);
    			g.fillRect(buttonArea);
    		}
    	} 

Best Regars!

The setColour function is Ok.

void buttonClicked(Button* button) override
	{
		if (button == &(downpanel.downmiddlepanel.downmiddlemodules[0]->ON_1))                                                      // [3]
		{
			int In_Out = 1;
			int channel = 0;
			if (ch0_on_status == "off")
			{
				button->setColour(TextButton::buttonColourId, Colours::green);
				auto m = MidiMessage::noteOn(In_Out, channel, uint8(127));
				m.setTimeStamp(Time::getMillisecondCounterHiRes() * 0.001);
				CurrentOutDevice->sendMessageNow(m);

				auto m1 = MidiMessage::noteOff(In_Out, channel, uint8(0));
				m1.setTimeStamp(Time::getMillisecondCounterHiRes() * 0.001);
				CurrentOutDevice->sendMessageNow(m1);
				ch0_on_status = "on";
			}
			else
			{
				button->setColour(TextButton::buttonColourId, Colours::black);
				auto m = MidiMessage::noteOn(In_Out, channel, uint8(0));
				m.setTimeStamp(Time::getMillisecondCounterHiRes() * 0.001);
				CurrentOutDevice->sendMessageNow(m);

				auto m1 = MidiMessage::noteOff(In_Out, channel, uint8(0));
				m1.setTimeStamp(Time::getMillisecondCounterHiRes() * 0.001);
				CurrentOutDevice->sendMessageNow(m1);
				ch0_on_status = "off";
			}
		}