Re: Restraining window movement + gridding
Re: Restraining window movement + gridding
- Subject: Re: Restraining window movement + gridding
- From: "Alastair J.Houghton" <email@hidden>
- Date: Thu, 16 Oct 2003 11:24:46 +0100
On Thursday, October 16, 2003, at 12:40 am, Rolf wrote:
Hi,
I need to restrain window movement in my app as follows:
- Gridding: It must only allow to have origins that are evenly
divisible by X, for example 0,4,8,12, etc.
- Restrain: No sides are allowed to move outside of visible screen
area.
I assume a possible solution to this is using
NSWindowWillMoveNotification. However the following does not work
(windowWillMove is never called), and I don't understand why:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillMove:)
name:@"NSWindowWillMoveNotification" object:self];
Why do that? It's much easier just to set-up a delegate for your
window; the delegate is automatically registered for the
window-will-move notification by the NSWindow code. Plus, the way the
above is written, it looks as if you have subclassed NSWindow, which is
probably unnecessary.
Just implement -windowWillMove: and -windowWillResize:toSize: on your
delegate object.
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.