• 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: Selecting objects, help needed...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting objects, help needed...


  • Subject: Re: Selecting objects, help needed...
  • From: Brian Webster <email@hidden>
  • Date: Mon, 13 Aug 2001 13:41:01 -0500

On Monday, August 13, 2001, at 11:23 AM, cocoa-dev-
email@hidden wrote:

I have a problem with the drawing of a selection rectangle.

I have an NSView with subviews in it,

the subviews happen to be selectable objects.
When I drag the mouse around, I would like to be able to draw a selection
rectangle above everything. Problem is that I have no control (AFAIK) on the
order things are drawn so if i put my drawing function in the container, I end
up with the subviews being drawn above my selection rectangle, which is not
good... And I can't check on each selected item to see if it intersects the
border of my selection rectangle and draw a line over itself, that's simply
not efficient at all (I can have quite a large number of [nested] subviews...

How have you guys (and ladies?) managed to do this kind of thing?

I think you might want to rethink your design of having each object in a separate subview of your main view. Take a look at Apple's Sketch.app example, and you'll see that there is only one NSView class, SKTGraphicView. It just holds a set of graphics objects to draw and then tells each one to draw itself in a rect inside the view. If there is a selection rectangle being dragged, it simply draws the rectangle's outline after having asked all the graphics to draw themselves.

As far as the zoom problem goes, say you want to zoom your view to 200%. You could just double the frame size (the bounds will be automatically doubled as well) and then multiply the coordinates that each graphic is drawn it by 2. That way, the graphics will be drawn at the same size, but there will be twice as much space and they will be separated by twice as great a distance.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Follow-Ups:
    • Re: Selecting objects, help needed...
      • From: Charles Jolley <email@hidden>
  • Prev by Date: Re: cocoa-dev digest, Vol 1 #388 - 15 msgs
  • Next by Date: Re: E-mail
  • Previous by thread: Selecting objects, help needed...
  • Next by thread: Re: Selecting objects, help needed...
  • Index(es):
    • Date
    • Thread