Hi list,

I have a window with a custom view that occupies the entire window, so the little resize corner in the lower right is within the bounds of the view. I noticed that when I draw into the window from the main thread (i.e. the usual way) that resize corner is redrawn when the view is redrawn. However, when I update the view from another thread, that doesn't happen. What am I missing?

I made a test app that just draws a black background in a custom view (MyCustomView) to show the problem. Here's the relevant code in the custom view:

- (void)drawFromSecondaryThread:(NSRect)rect
{
        [NSGraphicsContext saveGraphicsState];
        NSRectClip(rect);
        [[NSColor blackColor] set];
        NSRectFill(rect);
        [NSGraphicsContext restoreGraphicsState];
}

And in the object that has the view as an instance variable (MyCustomView *view). The method updateView is called from a repeating NSTimer that's attached to the run loop of the secondary thread.

- (void)updateView
{
        if (useSecondaryThread) {
                if ([view lockFocusIfCanDraw]) {
                        [view drawFromSecondaryThread:view.bounds];
                        [[view window] flushWindow];
                        [view unlockFocus];
                }
        } else {
                [view setNeedsDisplay:YES];
        }
}

Thanks for any help!
Hank

Hank Heijink
[EMAIL PROTECTED]



_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to