On May 6, 2013, at 16:17:49, Thomas Wetmore <t...@verizon.net> wrote:
> Is there a way to restrict the movement of an NSWindow to a frame of another > window (that may underly it) or to some other fixed rectangular sub-area on > the screen? > > Searching the web there was a CocoaBuilder thread 12 years ago that indicates > that it was unknown how to do this then, implying that optimization in the > Window Manager was an issue, but holding out the possibility that a layer > below Cocoa might allow it. > > The windowWillMove: delegate method does not allow vetoing the move. In > contrast to the windowWillResize:toSize: delegate method that does allow > resizing to be vetoed. > > If your answer to this question would be to ask me why I should want to do > such a thing, please consider that that is not an answer. I had a thread about snapping windows as they move or resize recently, so check the archives. Apple offers no easy way to do this. I had to override sendEvent:, catch NSLeftMouseDown, check to see if the click was in the titlebar, if so, set some instance variables that says we're dragging the window. Also catch NSLeftMouseDragged (if we know we're dragging the window) and calculate the new rect based on the mouse movement and the windows I wanted to snap to. Finally catch NSLeftMouseUp to reset my instance variables. -- Steve Mills Drummer, Mac geek _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com