On Feb 23, 2012, at 04:04 , Markus Spoettl wrote:

> As an illustration for the list, I have logged coordinates of a mouse move 
> and a subsequent mouse down event that followed the move event:
> 
> mouseMovedToPoint:NSPoint: {217.15625, 343.3984375}
> mouseDownAtPoint:NSPoint: {217, 344}
> 
> It can (and does) happen that the hit-tests in -mouseMoved: and -mouseDown: 
> return different objects that my view displays. My objects can be very close 
> to each other and 1 pixel actually makes a difference.
> 
> Anyone know how to work out mouseDown coordinates one can expect to get when 
> looking at mouseMove coordinates?

I'll ask the stupid question:

How do you know (or, why do you assume) that these two sets of coordinates 
represent the same point? Even if the user did a press-and-hold, a 
high-resolution input device might detect some "movement" in the position. (At 
a sub-pixel level, I guess everyone has fat, wobbly fingers.)

Or, looking at it from the other end, in many applications it's desirable to 
debounce the mouse position at the beginning of dragging, to prevent unwanted 
short drags. By "debounce", I mean deferring the initial move of the dragged 
object until the mouse position has moved by at least a couple of pixels from 
the mouse-down position. In such a scenario, a mouse-moved location has to be 
co-ordinated with the dragging state. I think your scenario is similar -- 
whatever code is using the mouse-moved position must take account whether the 
mouse is already down.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to