[Drawkit] Hit testing at high scale factor

Brad Larson larson at sonoplot.com
Tue Jul 1 10:49:13 PDT 2008


On Jun 30, 2008, at 7:05 PM, Brad Larson wrote:
>
> That solves the problem, and seems to work well even at high scale  
> factors.  Thanks.  The only weirdness with this is that for my  
> custom point subclass I'm getting "_segmentIndexForElementIndex::  
> index (4) beyond bounds (2)" messages on the console when I try to  
> drag the point, which no longer causes the point to move.  This  
> probably has something to do with the weird path I use behind the  
> element, so I'll see if I can find what's triggering that.
>
> In terms of the overlarge bounds that were being returned, I saw  
> this in DKDrawablePath:
>
> - (NSRect)			bounds
> {
> 	NSRect	r = NSInsetRect( [[self renderingPath] controlPointBounds],  
> -3, -3 );
>
> which would make the bounds wider and taller by 6.0 points, the size  
> difference I'm seeing.  What does this provide cushioning for in the  
> path: the knobs? Later on in the bounds method, it looks like the  
> width of the style is taken into account.  In any case, it's an  
> absolute value, not a scaled one.  Converting this to be
>
> 	NSRect	r = [[self renderingPath] controlPointBounds];
>
> fixes the selection rectangle issues that I was seeing with my  
> custom point subclass of DKDrawablePath, as well as the  
> DKDrawablePath lines I'm using.
>
>
> ______________________
> Brad Larson
> SonoPlot, Inc.
> 3030 Laura Lane, Suite 120
> Middleton, WI 53562


To fix this, I needed to override the mouseDraggedAtPoint: inPart:  
event: method in my custom subclass, because the method call

[[self path] moveControlPointPartcode:partcode toPoint:mp colinear:! 
cmd coradial:option constrainAngle:shift];

was trying to associate a partcode with my custom underlying path, and  
that wasn't going to work.  I just replaced the above method call with  
a [self setCenter:mp] and that did the trick.


______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562





More information about the Drawkit mailing list