Re: Cocoa Drawing
Re: Cocoa Drawing
- Subject: Re: Cocoa Drawing
- From: Uli Kusterer <email@hidden>
- Date: Mon, 4 May 2009 20:00:03 +0200
On 01.05.2009, at 12:20, DairyKnight wrote:
Hi, all
I'm trying to build a simple scribble program with Cocoa, and got
some
questions I couldn't solve. Hope someone here could help.
1. How can I perform a proper drawing in somewhere else rather than
drawRect: ? Like the Win32 GetDC(HWND) and ReleaseDC. (Sorry I'd use
lots of
Win32 analogy, coz
I've been a Win32 developer for quite a while.)
2. In the program what I did was respond to mouseDrag and call
[NSView
display]. In drawRect I draw all the scribble lines using
[NSBezierPath
strokeLineFromPoint]
But it seems the Mac Windows Manager would automatically clean out
the whole
drawing area. Is there a way to avoid this? Like the
InvalidRect(HWND, 0,
FALSE) in Win32.
Not sure what you're trying to do, but generally, the answer is "you
don't". You *always* draw from drawRect:. If you want to initiate
drawing, call -setNeedsDisplay: or -setNeedsDisplayInRect: to tell
AppKit that it should call drawRect on your view.
For cases where that doesn't help, draw into an NSImage, then draw
that from your drawRect. You can lockFocus on your NSImage at any
time, then your view can draw it later as a whole.
3. I used NSTrackingArea first, but it seems not able to respond to
mouse move with button pressed. But mouseDrag would only respond to
mouse
move with the left button
down. So there is no way to observe a mouse dragging with the right
button/mid button down on Mac??
rightMouseDragged: and otherMouseDragged:. They're just a couple
lines down in NSResponder's header.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden