Reputation: 918
MotionEvent has time_start
, time_update
and time_end
attributes. I thought they can be used to know if a touch has already ended or not, but it looks like not. Here is the code that can confirm that.
from kivy.app import runTouchApp
from kivy.lang import Builder
runTouchApp(Builder.load_string('''
Widget:
on_touch_down:
t = args[1]
has_not_moved = t.time_start == t.time_update
has_not_ended = t.time_end == -1
print(t.uid, has_not_moved, has_not_ended)
'''))
When I mashed a mouse button, I expected the output to be like this:
# I expect there is no False
1 True True
2 True True
3 True True
.
.
15 True True
but the actual output was
1 True True
2 True True
3 True True
.
13 True False
.
15 False False
.
20 False True
Why sometimes False
was printed? Is there a guaranteed way to know if a touch has already ended or not?
the source code of MotionEvent
Upvotes: 0
Views: 50
Reputation: 29488
I don't know exactly what's going on here because I didn't check the source, but maybe it's something like surprising behaviour happening if you manage to touch and release within the same frame.
Is there a guaranteed way to distinguish touches?
You get a different touch object for each touch, so they are automatically distinguished.
Upvotes: 1