Sending false mouse clicks whilst dragging?


I have a component which contains multiple sliders arrayed horizontally representing a sequence of velocities. I'd like to make it so that if the user drags laterally from one of the sliders, instead of continuing to affect that slider, each slider that the user drags over gets set to the Y position of the mouse as it enters that slider.

I don't think I have explained myself very well, but essentially I'd like to make it so that the user can quickly set all the sliders by dragging the mouse laterally over all of them.

I've tried subclassing Slider and trying to send fake mouseDown and mouseUp callbacks from mouseEnter & mouseExit, but while the user is dragging from the original Slider, mouseEnter & mouseExit don't seem to get called for the Slider under the mouse. Can anyone think of a workaround for this?


Ah, as so often happens, I have discovered the answer to my own question shortly after posting a question. I subclassed Slider, and it looks like this:

class SeqSlider : public Slider
    SeqSlider (SliderStyle style, TextEntryBoxPosition textBoxPosition)
    : Slider(style, textBoxPosition) {}
    void mouseDrag (const MouseEvent& e)
        auto s = dynamic_cast<SeqSlider*>(e.originalComponent);
        if (!(std::abs(e.getDistanceFromDragStartX()) > getWidth()/2))
            Desktop& d = Desktop::getInstance();
            Component* c = d.findComponentAt(d.getMousePosition());
            if (dynamic_cast<SeqSlider*>(c))

I know this is rather inefficient, but it seems to work smooth enough for me (premature optimization etc...). However, if anyone can come up with a better way, I'd still be interested to know!


I would do this by placing all the sliders into a component and then using that component's mouse methods to control the positions of the sliders. Anyhow, I'm almost certain I saw one of these posted to the "useful tools and components" forum. I came across is recently when looking for something else, but I can't seem to find it now. But I am almost sure it's there somewhere!