Re: Newbie NSView question.
Re: Newbie NSView question.
- Subject: Re: Newbie NSView question.
- From: "Alastair J.Houghton" <email@hidden>
- Date: Wed, 15 Oct 2003 09:19:08 +0100
On Wednesday, October 15, 2003, at 07:20 am, db_ wrote:
I'm doing a small simple application to help my understanding of
Cocoa. In a part of it is an NSView that I want to draw shapes in
depending on which button I click. I've connected all the buttons to
a corresponding function (drawCirlce, drawXXXX, etc). When I build
and run the app the drawing functions aren't drawing anything into the
view. I've added debug messages and know the functions are being
called.
So my question is... is drawRect: the only function that allows
drawing into an NSView? Thanks for any help.
No, but if you want to draw from elsewhere, you need to call -lockFocus
and -unlockFocus on your view. Apple recommends that you use
-drawRect: and -setNeedsDisplay: (or -setNeedsDisplayInRect:) in most
cases, because it allows the system to determine when to redraw your
view (so redraw requests can be optimised), whereas using -lockFocus
and -unlockFocus doesn't allow the system to do so.
Oh. When Panther and Xcode are released am I gonna have to relearn
all this stuff? Just curious. :)
No. XCode is very similar to Project Builder, and the Cocoa code that
you write is exactly the same; XCode and Project Builder don't
implement Cocoa... Cocoa is a framework that can be used by any
program, even if you compile it from the command line.
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.