[Drawkit] Hit testing at high scale factor
Brad Larson
larson at sonoplot.com
Tue Jul 1 10:49:15 PDT 2008
On Jun 30, 2008, at 11:28 PM, Graham Cox wrote:
> Indeed, this code is incorrect. I have changed it to:
>
> - (NSRect) bounds
> {
> // get the true knob size so we can factor that in accurately
>
> NSRect kr = [[[self layer] knobs]
> controlKnobRectAtPoint:NSZeroPoint ofType:kDKOnPathKnobType];
>
> float kbs = kr.size.width * 0.5f;
>
> NSRect r = NSInsetRect( [[self renderingPath] controlPointBounds], -
> kbs, -kbs );
>
> // factor in style allowance
>
> NSSize allow = [self extraSpaceNeeded];
> r = NSInsetRect( r, -allow.width, -allow.height );
>
> return r;
> }
>
>
> It needs to factor in the size of the knobs so they are always
> within the bounds, but should not assume their size since it varies
> with view scale. This code still makes the assumption that the knobs
> are the same size regardless of type, but that is true for a path
> object.
Cool. With this and the last few corrections you suggested, all of my
paths and custom objects at my high scale factor have reliable and
accurate hit detection behavior for clicking and drag-selecting.
______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562
More information about the Drawkit
mailing list