juce::ComponentBoundsConstrainer - how does it work?

Hi, can anyone explain how this works?

I’ve created one my own of these so I could override checkBounds().

When initialising my editor window I add this to the window.

I then call setSizeLimits() to set the constraints to 200,400 for min and max.
I also set checkBounds() to return a bounds size of 200,400.

However, I can still drag the window to whatever size I want it to be.

Am I missing something? thx

I usually do this:

In the parent component I declare the constrainer, and in the constructor:
constrainer.setMinimumOnscreenAmounts(getHeight(), getWidth(),getHeight(), getWidth());
Then I pass the constrinaer as a reference to a child component, and the child will hit walls as he touches the parent bounds when dragged around. The constrainer does not affect the parent.

Never used it for resizing though, but try to work from there.

1 Like

Thanks. Yeah, I can get it working in that way, I was just hoping that the constrainer would also constrain the main window but I can’t seem to figure this out.