Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

drag event
Started by horacebury Feb 16 2019 09:12 AM

20 replies to this topic

Best Answer schroederapps , 25 February 2019 - 08:32 AM

Last update: the pull request got approved and as of daily build 2019.3466 touch events xDelta and yDelta properties! :) 

 

https://developer.coronalabs.com/release/2019/3466/

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

I've noticed that listening for the drag event on the Runtime causes touch event-like event to be generated. I also can't find this in the docs.

 

Am I going mad?



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,761 posts
  • Corona SDK

Drag event?



[TOPIC: post.html]
#3

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

local function drag()
    print("this will print a lot")
end

Runtime:addEventListener("drag",drag)


[TOPIC: post.html]
#4

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,761 posts
  • Corona SDK

Is this actually a feature? If it's not in the docs it must either be WIP or abandoned?



[TOPIC: post.html]
#5

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

That's what I said.

 

I'm on a Mac and it works in the Corona sim.

 

I can only assume it's an abandoned feature.

 

Passes this to the event parameter:

y	111.5022277832
x	183.18222045898
time	4123.057
name	drag
yDelta	-64
xDelta	132


[TOPIC: post.html]
#6

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,761 posts
  • Corona SDK

How did you come across it?

[TOPIC: post.html]
#7

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,548 posts
  • Corona SDK

I've never heard of a drag event and it is not listed in the API event list, so I would assume it is a dead feature.

 

PS - Yes, I know we're all saying 'it's not in the docs', but I don't think it hurts to say it a few times. :)



[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,548 posts
  • Corona SDK

Just for fun I went through old docs, all the way back to '2013.1218' and did not find a drag event.

 

PS - I'm one of those weirdos who likes do regularly download the API docs zip, just in case.



[TOPIC: post.html]
#9

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

I have a settings module which can dispatch any setting via Runtime when it changes. I happen to have a setting called ‘drag’ but found that listening for that event (the event name is the same as the setting name) I ended up with tonnes of events being generated. Took a while to figure that out.

[TOPIC: post.html]
#10

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

Well now I just find myself wishing that the 'xDelta' and 'yDelta' values were automatically supplied in touch events.  :blink:



[TOPIC: post.html]
#11

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

Yep, those are nice to have. #featurerequest

[TOPIC: post.html]
#12

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,088 posts
  • Corona SDK

@schroederapps what are xDelta and yDelta?



[TOPIC: post.html]
#13

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

@agramonte - just the difference between event.x and event.xStart (and y & yStart) - easily calcuable, but I like that they included it in drag events and think it’d be convenient to include it in touch events also. I may try to add it in myself now that Corona is open source. Seems like a low-pressure place to start learning how to edit Corona’s source code.

[TOPIC: post.html]
#14

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,088 posts
  • Corona SDK

@schroederapps exactly what I was thinking. You just have to copy and paste the code from the other location and test.



[TOPIC: post.html]
#15

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

Made a pull request into the source to add xDelta and yDelta properties to touch events. Hopefully it gets approved & merged and we'll have those values in all our touch events moving forward!

 

Gotta love how we're able to make these little usability tweaks ourselves now that Corona is open source! :)

 

https://github.com/coronalabs/corona/pull/17


  • horacebury likes this

[TOPIC: post.html]
#16

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

  Best Answer

Last update: the pull request got approved and as of daily build 2019.3466 touch events xDelta and yDelta properties! :) 

 

https://developer.coronalabs.com/release/2019/3466/


  • horacebury likes this

[TOPIC: post.html]
#17

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,561 posts
  • Enterprise

I'm unaware of any "drag" event that we support. Most people drag with the "touch" event.

 

And thank you for your updates @schroederapps.  Make sure to hit the link at the bottom of the touch event docs so I can update the docs with the new event members.

 

Rob



[TOPIC: post.html]
#18

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

@schroederapps Thank you - a lot of devs will appreciate this, me especially!

@rob I didn’t expect it either, but it’s definitely there. Have you tried it yourself?

[TOPIC: post.html]
#19

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,561 posts
  • Enterprise

@horacebury, no I haven't tried it since I didn't know it was there. Since it's undocumented, I'm running on the assumption you stumbled upon something an engineer was playing with years ago that got into the code and got forgotten.

 

Rob


  • horacebury likes this

[TOPIC: post.html]
#20

nugett

[GLOBAL: userInfoPane.html]
nugett
  • Observer

  • 26 posts
  • Corona SDK

back in 2010...

 

-Walter, do you remember that bezier curves script I was writing?

-Give me a sec, Carlos, I'm adding a drag event...

-F* the drag, I'm talking about a revolution here! Let me tell you...

 

...

 

 

 

 

Is this the first public commit?? This is history! Congrats! :)



[TOPIC: post.html]
#21

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

@nugett,

 

it was not the first public commit - there were a handful before this one, but thanks! However, I'm looking to make *another* one because it turns out the drag event code I pilfered does not play nice with content scaled devices - so basically if you define a "content" size in config.lua, the delta values it returns do not properly correspond to display coordinates. Hope to fix it soon!  :blink:




[topic_controls]
[/topic_controls]