• 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: Drawing outside of drawRect for NSView..
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing outside of drawRect for NSView..


  • Subject: Re: Drawing outside of drawRect for NSView..
  • From: "I. Savant" <email@hidden>
  • Date: Sun, 15 Oct 2006 10:15:05 -0400

Carter:

This is not the correct approach. Check out the Sketch example code in your Developer folder. Take your time to ferret out the selection code (for drag-selecting shapes in the drawing).

Basically, you want to define the starting point during your mouseDown: event. You'll also want a BOOL like "isSelecting". As the user continues dragging, keep updating the end point and flag your view as needing displayed. When the mouse button is released (ie NSLeftMouseUp), set isSelecting to NO and flag for display again.

In your drawRect: method, if "isSelecting", you take those two points, determine your rectangle, and draw your necessary selection adornments. If it's not selecting, don't draw the adornments -- since you'll be marking your view as needing display in the right places in your mouseDown: loop, the selection rectangle will 'disappear' when the mouse is released.

  I hope this helps.

--
I.S.


On Oct 15, 2006, at 9:35 AM, Carter R. Harrison wrote:

Is it possible to draw to a view outside of drawRect? For instance, what if I wanted to draw an NSRect when the mouseDown event is fired? Is this kind of thing bad practice? I've been trying to draw an NSRect to my view during the mouseDown event, but for reasons unknown to me the NSRect is being applied to the window and its coordinate system rather than my view's (and yes I used convertPoint:toView:). Thanks in advance.

----------------------------------
Carter R. Harrison
email@hidden
----------------------------------



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Drawing outside of drawRect for NSView.. (From: "Carter R. Harrison" <email@hidden>)

  • Prev by Date: Re: The buttons at the bottom of a list
  • Next by Date: Re: Change NSTableView Drop Highlight (ugly black box)
  • Previous by thread: Drawing outside of drawRect for NSView..
  • Next by thread: NSImage Memory Management: To Page Or Not To Page.
  • Index(es):
    • Date
    • Thread