Click and drag across multiple buttons

What is the cleanest method to click on a button and drag across other buttons and have them change their state?


A vertical row of buttons representing the mute states for each sequencer track. Click on the first button and then drag across the others to change their state as if they were clicked on.

Surprisingly tricky to do this! The way juce (and almost all GUI frameworks) work is that components capture the mouse when clicked, and continue to receive drags until released, which makes it hard to pass the events onto other components when the mouse exits.

So to do this kind of thing, you could somehow make all the mouse events go through the buttons and be handled by a parent component. Or make all the buttons MouseListeners which receive events from each other.. But either way there'd be a bit of messing-about to get them to update their state correctly.

I was just hoping for a quick clean method.

I solved it in the button drag routine by having the parent trigger clicks on all similiar buttons .