Re: Drawing background windows during window move.
Re: Drawing background windows during window move.
- Subject: Re: Drawing background windows during window move.
- From: Michael Ash <email@hidden>
- Date: Tue, 17 Mar 2009 23:13:49 -0400
On Tue, Mar 17, 2009 at 1:38 PM, Garrett Moon <email@hidden> wrote:
> I have two windows in an application, a GuideWindow and a RegularWindow. The
> GuideWindow covers all screens and displays guide lines that match up with
> the edges of the contentView in RegularWindow. When RegularWindow is moved
> or resized, GuideWindow updates its display to move the guide lines with it.
> This is achieved through windowDidResize notifications and windowDidMove
> notifications. when doing a resize, everything works perfectly with the
> guide lines updating as the RegularWindow is resized.
>
> However, windowDidMove is only called when the user pauses while moving
> RegularWindow. So I subclassed RegularWindow and made windowDragged send an
> NSWindowDidMoveNotification (sloppy, I know). This calls the update method
> of GuideWindow properly, but it still doesn't draw until the user pauses.
>
> I've got some NSLogs in the guide update function, so I know it's being
> called, but no drawing. I've tried sending the display method to all of the
> GuideWindow views and to the GuideWindow itself with no avail. I've also
> tried updating and flushing the window.
>
> Am I missing something? Are only certain drawing events called in the event
> loop when a window is being dragged? Could this have to do with window
> backing? Thanks in advance,
Window movement in Cocoa is done asynchronously by the window server.
This is what lets you smoothly move windows in apps that are heavily
using their main runloop, and what lets you move windows at all in
apps that are hung. Generally it's a useful thing. But the trouble is
that it's inherently asynchronous, so the sort of thing you're trying
to do simply cannot work.
You have a couple of options here:
1) Make the window that draws your background grid a child of the
window that can move around. This will cause the window server to move
it along with the main window. Obviously for this to work in this
scenario, the window will have to be large enough that the user can't
expose the edges of it no matter how far they move.
2) Somehow disable the default window moving behavior and reimplement
it yourself to work in a synchronous, controlled manner.
Personally I'd recommend option #1, as #2 is likely to be difficult,
fragile, and produce dragging that's not very smooth, but obviously
the choice is yours.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden