• 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
NSBezierPath Hit Detection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath Hit Detection


  • Subject: NSBezierPath Hit Detection
  • From: email@hidden
  • Date: Wed, 26 Sep 2001 09:25:40 -0400

Hi,

I'm trying to use the containsPoint method for hit detection of NSBezierPaths on mouseUp in an NSView. But the only hex that my method ever detects is the first one in the array.

I've broken the NSView up into an array of frames, each frame has an NSBezierPath drawn in it to represent the hexagon. After I draw the path, I add it to another array if necessary.

if ([[pathArray objectAtIndex: row] objectForKey: [NSNumber numberWithInt: column]] == nil)
{
[[pathArray objectAtIndex: row] setObject:[path copy] forKey:[NSNumber numberWithInt: column]];
}

I do this so that after I get the eventLocation of the mouseUp I can run through the array of paths and check each path for containsPoint.

NSPoint eventLocation = [self convertPoint:[event locationInWindow] fromView: nil];

if ([[[pathArray objectAtIndex: row] objectForKey:[NSNumber numberWithInt: column]] containsPoint: eventLocation])
{
NSLog(@"Row: %i, Column %i", row, column);
return;
}

This works correctly for the first path only and I believe it's because every path added to the array has the same info as the first one. How can I make sure each one I add is unique?

Ken Botwinick
http://homepage.mac.com/kenbotwinick
AOL IM Screen name: kenbotwinick


  • Prev by Date: Re: Adding custom inputs to NSRunLoop
  • Next by Date: Re: NSBezierPath Hit Detection
  • Previous by thread: Re: PreferencePane examples?
  • Next by thread: Re: NSBezierPath Hit Detection
  • Index(es):
    • Date
    • Thread