Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

3D Touch Haptic Touch and Corona touch events
Started by dan56 May 11 2019 07:06 AM

3 replies to this topic
3d touch haptic touch event long press
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

dan56

[GLOBAL: userInfoPane.html]
dan56
  • Enthusiast

  • 43 posts
  • Corona SDK

My algorithm for detecting a “long press” in my Corona app has been

  1. On a touch/ begin event, set up a long press timer
  2. On a touch/end or touch/cancel events, cancel the timer
  3. On a touch/move event cancel the timer
  4. If the timer times out, declare that a long press has been detected

This has worked fine on Android phones, and on iPhones up until today. In experimenting with an iPhone X, my app could not detect a long press.

 

Is it possible that the 3D touch feature, or maybe haptic touch, causes Corona to send a move or end or cancel event before the user _completely_ removes his finger from the screen?

 

 



[TOPIC: post.html]
#2

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

Just a hunch, but the higher resolution on the iPhone X could be detecting movements more sensitively than your other devices. I’d suggest building in an allowance for accidental movements. So instead of cancelling the timer anytime a moved event is fired, calculate the distance the user’s finger has traveled from the origin x/y values and only cancel the timer if it crosses a threshold like 10 pixels.

[TOPIC: post.html]
#3

dan56

[GLOBAL: userInfoPane.html]
dan56
  • Enthusiast

  • 43 posts
  • Corona SDK

Thanks for the idea! I was thinking of that too, and I may still try a fix for that idea, but then I remembered some contrary evidence.

 

The contrary evidence is…

I have another instance in my app where I ignored movement. In that instance, only a touch/end or touch/cancel would cancel the timer (so no step 3 in the above description). Or, sort of like a move threshold of an infinite number of pixels. :)

 

Anyway, in that instance, it still didn't work -- no long press was detected.

 

However, I just thought of this idea in support of the original theory…

Maybe the iPhone X is so sensitive that the user always makes a series of tiny movements that result in a bunch of touch/begin, touch/move, and touch/end messages (that settle out to the right state)  but Corona can’t keep up with setting, cancelling, then resetting the timer(s) that frequently.

 

 

Here's another thought. What happens if the user changes pressure during a long press? For example, say, the user gradually increases pressure then decreases pressure during a long press. If Corona implements the following event sequence

 

begin-light pressure

begin-medium pressure

begin-heavy pressure

end-heavy pressure

end-medium pressure

end-light pressure

 

that work work for my code. But if the Corona sent the following event sequence

 

begin-light pressure

end-light pressure

begin-medium pressure

end-medium pressure

begin-heavy pressure

end heavy pressure

 

those end messages would be bad for my implementation.



[TOPIC: post.html]
#4

dan56

[GLOBAL: userInfoPane.html]
dan56
  • Enthusiast

  • 43 posts
  • Corona SDK

Not hearing an better ideas, I went ahead and implemented the "tiny movements filter" as suggested by schroederappsThat is, "the iPhone X could be detecting movements more sensitively than your other devices... calculate the distance the user’s finger has traveled from the origin x/y values and only cancel the [long press] timer if it crosses a threshold" 

 

That fix worked! It fixed the main instance of the problem! And, more good news, the problem report ion the other instance of the problem  (which already had a "movements filter" in a way) turned out to be a false report. So, all is good -- for the moment. :)

 

Thanks for the help!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: 3d touch, haptic, touch event, long press