If you want to draw outside of drawRect:, try calling lockFocus on your content 
view first.  Then, to get an NSGraphicsContext, call [NSGraphicsContext 
currentContext].  When you are done drawing, call unlockFocus, again on your 
content view.  Also, in my experience, if you draw outside of drawRect: you 
need to call flushWindow yourself after calling unlockFocus to get reliable 
screen updates.

Paul Sanders.

----- Original Message ----- 
From: Bill Appleton 
To: vincent habchi 
Cc: Paul Sanders ; cocoa-dev list 
Sent: Wednesday, April 28, 2010 7:29 PM
Subject: Re: white screen windows at first


hi all,

i have been working on this a lot & have some new information

previously i was using carbon and core graphics

when i draw to the screen, sometimes it is in the update event but sometimes it 
was in response to a mouse click, or some other event

this always worked:


QDBeginCGContext(grafptr, &cgContext);
CGContextSaveGState(cgContext);

draw with core graphics here...

CGContextRestoreGState(cgContext);
QDEndCGContext(grafptr, &cgContext);


but when i switched to cocoa, i started doing this:


cgcontext = [[myNSWindowPtr graphicsContext] graphicsPort];
CGContextSaveGState(cgContext);

draw with core graphics here...

CGContextRestoreGState(cgContext);


this appears to only work from inside the drawRect routine, if i get here from 
some other event it doesn't work

so is it "legal" to draw on an NSWindow from some other event? 

if not, what the heck does QDEndCGContext do that makes it work?



thanks,

bill
_______________________________________________

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 arch...@mail-archive.com

Reply via email to