I am attempting to drag a component within a fixed area, but I am not having any joy in doing so. I figure I must be doing something obviously wrong, but am new to C++ and Juce.. .
My component is drawn, and the required limits are within an area of the main component, so can't use the setMinimumOnscreenAmounts, so am attempting to use checkBounds. In my component I have a constrainer, as such:
ComponentBoundsConstrainer constrainer;
In my main component I calculate the Rectangle<int> limits to restrict the area in which the component may move, which is provided to the component. In my components mouseDrag I attempt to use the constrainer.checkBounds to limit where it can be dragged to.
void myComponent::mouseDrag (const MouseEvent& e) { Rectangle<int> bounds(0, 0, 100, 100); Rectangle<int> previousBounds(getX(), getY(), getWidth(), getHeight()); constrainer.checkBounds(bounds, previousBounds, limits, false, false, false, false); }
But this appears to have no effect... I'm obviously doing something wrong, so, um, what part am I missing?