discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing aside of -drawRect


From: Fred Kiefer
Subject: Re: Drawing aside of -drawRect
Date: Wed, 10 Sep 2003 20:01:46 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

Tima Vaisburd wrote:
I have problems with drawing in any method but [NSView -drawRect].

I placed the drawing code directly in the mouse event processing
handler, like this:

// This is a method of NSView subclass

- (void) mouseDragged:(NSEvent *) event
{
        NSPoint sketch_origin = ... ;

        [self lockFocus];

        // NSImage * _sketch, * _mask defined elsewhere

        [_sketch compositeToPoint: sketch_origin operation: NSCompositeCopy];

[_mask compositeToPoint: sketch_origin operation: NSCompositeSourceOver];

        [self unlockFocus];
    }
}

Nothing happens when the backing store is buffered or retained.
What do I miss?


The short answer here is never to draw outside of the drawRect: framework. You could always mark the area as needing a refresh and give the run loop a chance. If you still belive that you have to do the drawing here and are sure that this is the main thread, what you need to add is
[_window flushWindow];
But don't tell anybody I helped you to draw where you should not. :-)

Cheers
Fred






reply via email to

[Prev in Thread] Current Thread [Next in Thread]