Hey guys, the ComponentBoundsConstrainer class documentation is really confusing to me. I would like to see if anyone could give an example on how to use it within a draggable component(as above) to constrain it to a rectangle inside Its parent component. For example lets say a Rectangle (10,10,100,100) .
Calling setMinimumOnScreenAmounts() inside mouseDown() works perfectly, so I thought constraining it to a specific Rectangle would be somehow similar, but I can’t get it work. Cheers!
class BreakpointComponent : public Component
{
public:
BreakpointComponent();
~BreakpointComponent();
void paint (Graphics&) override;
void resized() override;
ComponentDragger breakpointDragger;
ComponentBoundsConstrainer constrainer;
void mouseDown(const MouseEvent& e) {
breakpointDragger.startDraggingComponent(this, e);
}
void mouseDrag(const MouseEvent& e) {
breakpointDragger.dragComponent(this, e, &constrainer);
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BreakpointComponent)
};
