[Drawkit] Hit testing at high scale factor
Brad Larson
larson at sonoplot.com
Fri Jun 27 15:34:02 PDT 2008
I've been experiencing a glitch with hit testing that I can't seem to
track down and thought I'd check to see if there was an obvious
solution to it. What I'm experiencing is that when I click to the up
and left of an object, I select it, even though I'm a ways away from
the object. This happens in a square starting a the object and going
up and to the left. It does not occur below or to the right of the
object. From logging positions, it looks like the hit testing is
marking a hit in a region up to 1.0 points to the left and up of the
object. That is, any click within that region is a hit on the
object. At the high scale factors (~500) we use for our micron units,
this can be a significant distance and really complicate object
selection.
Oddly, this is not a problem for control points, only the selection
and movement of the bulk paths. I've traveled down the hit test
chain, and it looks like the appropriate transformed view coordinates
are being used all the way down. The object bounds are giving me some
weird results, in that they are showing a bounds of 6.0 points for the
small paths and objects we're working with, when the bounds should be
around 0.12 points or lower. There are some 6.0 point constants in
DKKnob, but I checked that and it appears to be scaling properly to
the small sizes. In any case, the bounds should just be the start of
the hit test, with the actual testing done by lower-level items.
This weirdness happens with both custom DKDrawablePath subclasses as
well as DKDrawablePath itself. I haven't tried DKDrawableShape to see
how it responds.
Also, the point DKDrawablePath subclass seems to have a weird
selection behavior that may be related to this. When you move the
selection box over the point, it will be selected, but as you grow the
box to a certain size, the point will become deselected. If you
shrink the box, it will become selected again. This is less
noticeable on the DKDrawablePaths, but I still see some inaccuracies
in when the paths are selected by the box and when they are not.
Where else would you suggest I look: DKStyle, NSBezierPath? This is a
problem most people wouldn't encounter at their size scale, and I can
hunt it down myself if I know the general area that might be
responsible.
______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562
More information about the Drawkit
mailing list