On Apr 13, 2011, at 12:23, Tom Jeffries wrote:
> I seem to be missing something, and it's probably something quite obvious.
> In the initialization to an NSView subclass window, I do the following:
>
> - (void) drawRect:(NSRect)dirtyRect
> {
> [StepWindow DrawStepArea];
> }
> It works perfectly when the window is first initialized. However, when I
> call DrawStepArea later nothing gets drawn. I'm calling from another class,
> but everything about the call works fine including access to variables in
> the StepWindow class.
This isn't how drawing works. You shouldn't be calling 'drawRect:' (or any
method that draws) directly. Instead, send the view a 'setNeedsDisplay:' or
'setNeedsDisplayInRect:' message. Eventually, the frameworks will call
'drawRect:' after setting up the drawing environment properly, and the view
contents should then get redrawn.
At the very least, the information here:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/DrawingEnviron/DrawingEnviron.html
is essential knowledge for anyone trying subclass NSView, as is this entire
document:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html
but especially:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/SubclassingNSView.html
_______________________________________________
Cocoa-dev mailing list ([email protected])
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]