defold-input icon indicating copy to clipboard operation
defold-input copied to clipboard

Request: Distance from origin on drag

Open Trevortni opened this issue 4 years ago • 6 comments
trafficstars

I suppose this is my fault that I didn't realize this earlier, but I'm pretty sure dx and dy only give the distance traveled since the last frame. Would it be possible to get a pair of extra values representing the distance from where the mouse button was first pressed?

For that matter, just knowing where the mousedown first occurred could be useful as well, though I only really need one or the other at the moment (since having one gives you the other via math).

Trevortni avatar Jun 13 '21 05:06 Trevortni

You should get a drag start event I think. And it should contain a starting position.

britzl avatar Jun 13 '21 05:06 britzl

You should get a drag start event I think. And it should contain a starting position.

This is in the drag start event. Well, it's in the listener for the drag start event, anyway. If there's a starting position there, I don't see it.

image

Trevortni avatar Jun 13 '21 05:06 Trevortni

Isn't the x & y values the starting position?

britzl avatar Jun 13 '21 05:06 britzl

Here's dragging the same object from the same starting point the opposite direction:

image

Trevortni avatar Jun 13 '21 05:06 Trevortni

I'm pretty sure x and y are the current cursor position.

Trevortni avatar Jun 13 '21 05:06 Trevortni

Ah, true, it is not the same as the initial pressed position, but rather the position when the drag started (ie when moving the cursor above the drag threshold).

britzl avatar Jun 13 '21 07:06 britzl