Lambdas for ResizableBorderComponent: onDraggingStart, onDragging, onDraggingEnd

It would be awesome to be able to react to ResizableBorderComponent’s mouse events.

Adding an onDraggingStart, onDragging and onDraggingEnd lambda would help a lot.

My use case is, when I release the dragging I want to write the change into a configuration.

Thanks for consideration.

For time being I use this little class:

class BorderDragger : public juce::ResizableBorderComponent
{
public:
    BorderDragger (juce::Component* component, juce::ComponentBoundsConstrainer* constrainer = nullptr) : juce::ResizableBorderComponent (component, constrainer) {}
    std::function<void()> onDragStart, onDragging, onDragEnd;

    void mouseDown (const juce::MouseEvent& event) override
    {
        if (onDragStart) onDragStart();
        juce::ResizableBorderComponent::mouseDown (event);
    }

    void mouseDrag (const juce::MouseEvent& event) override
    {
        juce::ResizableBorderComponent::mouseDrag (event);
        if (onDragging) onDragging();
    }

    void mouseUp (const juce::MouseEvent& event) override
    {
        juce::ResizableBorderComponent::mouseUp (event);
        if (onDragEnd) onDragEnd();
    }

private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BorderDragger)
};

So I can do fun stuff like this:

1 Like

I’ve made similar wrappers for hires timers and threads… lambdas changed everything… :slight_smile:

2 Likes