How to determine whether the left mouse button is pressed down in the mouse move event

There are 20 buttons in the MianComponent of the juce gui project, I need that if the mouse enters the coordinates of any of the buttons while the left mouse button is pressed down, the button will be pushed down too. I have used event.mods.isLeftButtonDown() as the follow shows, but while the left mouse button is pressed , it doesn’t work at all.

MianComponent.h:

juce::TextButton sbutton[20]

MianComponent.cpp

void MainComponent::mouseMove(const juce::MouseEvent& event)
{

    if (event.mods.isLeftButtonDown())
    {
        // print code
        std::string message2 = "event.mods.isLeftButtonDown() :\n";
        OutputDebugStringA(message2.c_str());

        for (int i = 0; i < 20; ++i) {
            if (sbutton[i].getBounds().contains(event.getPosition()))
            {
                sbutton[i].ButtonPushed(i);  // customize ButtonPushed()
            }
    }     
}

Shouldn’t you be using isMouseOverOrDragging in the Component? Note also the different heuristics for whether you are on a tablet (touch event) or desktop (mouse event) device …

if you need something to continuously react to your left-hold input while considering all the components the drag crosses you might wanna not use 20 buttons but 20 custom component that setInterceptMouseClicks() (or hitTest false) back to its parent, which then has the mouseDrag method implemented to check for overlaps with those 20 components to determine which one you currently drag over to perform its action