• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Drawing


  • Subject: Re: Cocoa Drawing
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 4 May 2009 12:08:58 -0600


On May 1, 2009, at 4:20 AM, DairyKnight wrote:

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.)

You can lock and then unlock focus on a view manually to draw into it, though you probably shouldn't do this unless you have a really good reason. I'd recommend you keep all drawing code in -drawRect: and then use the needs-display methods if you need to invalidate something.


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.

Did you see the -setNeedsDisplayInRect: method in NSView?

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??

Did you see the -rightMouseDragged: and -otherMouseDragged: methods in NSResponder (NSView's superclass)?


Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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


References: 
 >Cocoa Drawing (From: DairyKnight <email@hidden>)

  • Prev by Date: Re: Storing a password (iPhone)
  • Next by Date: Re: Storing a password (iPhone)
  • Previous by thread: Re: Cocoa Drawing
  • Next by thread: Re: Cocoa Drawing
  • Index(es):
    • Date
    • Thread