As you know in 10.7 the windows can be resized by the user from all sides and corners. Is there any way to restrict the resizing of an NSWindow to only one side? Using setMinSize:and setMaxSize: won’t do everything: by using those you can only restrain the resizing to two sides, not one.
As you know in 10.7 the windows can be resized by the user from
Share
To fix the cursor, track the mouse position use the
mouseMovedevent of an NSWindow subclass. When it is close to the top, call setMinSize = setMaxSize = whatever size the window is. When the mouse is closer to the bottom than the top, change the min size and max size back to whatever will let the user resize in the way you want them to.Note that mouseMoved gets called whether the mouse is inside the window or outside of it (in my testing at least), as long as the window has focus. But for this to work, first implement
-(BOOL) acceptsMouseMovedEvents { return YES; }in your NSWindow subclass.As an extra safeguard, you can intercept and prevent any attempts at resizing using
windowWillResize(notwindowDidResize) in an NSWindowDelegate. From the Apple documentation: