Common-Gestures-Example

129 views
Skip to first unread message

Robert

unread,
Jul 11, 2021, 10:56:47 PM7/11/21
to Kivy users support

I just posted 'Common-Gestures-Example'  https://github.com/Android-for-Python/Common-Gestures-Example/blob/main/README.md

The class `CommonGestures` detects the common gestures for `scale`, `move`, `swipe`, `long press move`, `long press`, `tap`, and `double tap`.  It is easy to use, see the README.

The example demonstrates basic usage, a Screen that responds to a swipe, moving objects on a canvas, and an Image that zooms and pans its texture.

The gestures were written with Android in mind, but can be used on other platforms and input devices.

Elliot Garbus

unread,
Jul 12, 2021, 10:40:10 AM7/12/21
to kivy-...@googlegroups.com

Robert,

Another great contribution to the community!  Well done!

 

FWIW… the Windows Mouse disable is documented here: https://kivy.org/doc/stable/api-kivy.input.providers.mouse.html?highlight=disable_multitouch

 

-Elliot

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d6d95b26-05c9-46cc-9abd-ac866d37385bn%40googlegroups.com.

 

Robert

unread,
Jul 12, 2021, 4:53:12 PM7/12/21
to Kivy users support
Thanks, and for the doc link, I fixed the readme.

When you get some time could you please try the example on a Mac, I expect it will mostly (all?) work but I have no way to test.

Elliot Garbus

unread,
Jul 12, 2021, 4:57:16 PM7/12/21
to kivy-...@googlegroups.com
Will do!

Sent from my iPhone

On Jul 12, 2021, at 1:53 PM, Robert <planckp...@gmail.com> wrote:



Degenerate Tech

unread,
Jul 12, 2021, 11:27:07 PM7/12/21
to Kivy users support
awesome!! great work .. @Robert

Robert

unread,
Jul 15, 2021, 4:33:14 PM7/15/21
to Kivy users support
Elliot,
Did you get to try this on a Mac?

Elliot Garbus

unread,
Jul 15, 2021, 5:47:07 PM7/15/21
to kivy-...@googlegroups.com
Not yet. I’ll get to it soon. 

Sent from my iPhone

On Jul 15, 2021, at 1:33 PM, Robert <planckp...@gmail.com> wrote:



Elliot Garbus

unread,
Jul 16, 2021, 1:22:31 AM7/16/21
to kivy-...@googlegroups.com
Robert here is some feedback from some quick Mac testing.  I’d be happy to help debug some of the issue I am seeing.  I’ll look forward to your feedback.

Screen 1:
A right click on the touch pad or mouse will cause the red dot to appear.
The standard Mac track pad gesture for a swipe left of right is to swipe with 2 fingers.  The app does not respond the this gesture.
A tap/hold and drag will cause the screen to change, but there is an unnatural feeling time dependency.  The swipe must begin very quickly after the tap for the gesture to be recognized.  The screen transition happens after the hold is released.  It would be natural for the tradition to follow the swipe.

With a mouse pressing the mouse button and dragging, I get a constant behavior, but the animation starts when the mouse button is released. I would like to see the swipe move with the mouse.

Screen 2:
Trackpad
  • The Mac track pad has a tap a click and a deep click.  My track pad has the default settings and the tap to click is disabled. 
  • A double click is constantly recognized as a double tap. A single tap is not recognized.
  • Enabling Tap (third entry in the image) and the gestures are reported as expected.  The velocity data does not seem correct.  There are big jumps in values, it is not consistent with the speed of motion.
  • A long press or deep press are both reported as a long press.
Mouse:
  • Mouse behaves as expected in the gesture area.  Velocity data has the same issue as with the track pad.



Screen 3:
  • Consistent with Screen 2

Screen 4:
  • Selection and movement works as expected.
  • Does not respond to pinch and zoom.
  • Will scale up with the scroll wheel unit max size.  Then it stops responding.

Screen 5:
  • Pinch and zoom does not work.  If I use the red dot I can zoom.  A double tap will restore view.
  • Zooms with scroll wheel, or two finger scroll gesture on trackpad.

Let me know how I can help.

-Elliot



Robert

unread,
Jul 16, 2021, 10:30:46 PM7/16/21
to Kivy users support
Thanks Elliot, great feedback on Mac issues:

Executive summary:
================

1) Swipe detect time too short:
Try increasing https://github.com/Android-for-Python/Common-Gestures-Example/blob/main/commongestures.py#L44  Test with the last screen to see side effect.

2) Swipe waits until finger lift:
Try attached commongestures.py

3) Velocity number:
I think it appears wrong because it is over the previous 1/5 second. Try decreasing latency by decreasing this period: https://github.com/Android-for-Python/Common-Gestures-Example/blob/main/commongestures.py#L43

4)Does not respond to pinch and spread.
This one I will need help with. I have no clue. As I start I added a print statement to the attached to show how many touches there are. Assumption for pinch/spread is two. This will at least tell us which direction to look.

5) Scale up then stops responding.
There is an error in that example, currently re-testing.

6) Mac swipe gesture
Design goal was a set of common Android gestures that work on other platforms, rather than each platform's gestures. A possible future enhancement, not totally clear how to disambiguate. But all gestures for all platforms is probably an unrealistic expectation. Docs need to be clearer about that.


More Details
============


>>A right click on the touch pad or mouse will cause the red dot to appear.

This is Kivy behavior, it is possible to turn it off. But given pinch/spread behavior that may not be a good idea (yet?).


>> The standard Mac track pad gesture for a swipe left of right is to swipe with 2 fingers.  The app does not respond the this gesture.

Yes, the goal was Android gestures on desktops. There are some Windows gestures like this too.

>>A tap/hold and drag will cause the screen to change, but there is an unnatural feeling time dependency.  The swipe must begin very quickly after the tap for the gesture to be recognized.

Yes, if you want to experiment try increasing https://github.com/Android-for-Python/Common-Gestures-Example/blob/main/commongestures.py#L44  . You will see the side effect in the photo screen (a swipe must be disambiguated from a move).

Let me know what number you like.


>>The screen transition happens after the hold is released.  It would be natural for the tradition to follow the swipe.

Yes, try the attached.


>>With a mouse pressing the mouse button and dragging, I get a constant behavior, but the animation starts when the mouse button is released. I would like to see the swipe move with the mouse.

I don't think I understand this, probably because I don't know anything about the animation. To me, it sounds the same as the previous item


>>The Mac track pad has a tap a click and a deep click.  My track pad has the default settings and the tap to click is disabled.
>>.....

That all sound pretty good.


>>The velocity data does not seem correct.

It probably is correct since velocity is also used to detect swipe. Perhaps the latency is the issue? Try increasing the sample rate, by decreasing this https://github.com/Android-for-Python/Common-Gestures-Example/blob/main/commongestures.py#L43


>>A long press or deep press are both reported as a long press.

This might be a happy coincidence.

>>Mouse behaves as expected in the gesture area.  Velocity data has the same issue as with the track pad.

OK


>>Does not respond to pinch and zoom.

Well that is not good


>>Will scale up with the scroll wheel unit max size.  Then it stops responding.

Yes, I see that example seems to have some unresponsive behavior, I will investigate.

>>Screen 5:

OK
commongestures.py

Elliot Garbus

unread,
Jul 18, 2021, 3:01:52 PM7/18/21
to kivy-...@googlegroups.com
Robert,

Looks like you have made a number of updates.
Last night I experimented with the swipe time value.
I reduced the swipe detection time to 0.075, this feels more natural.
self._SWIPE_TIME          = 0.075               # sec original 0.1
I’ll update to your newest code and move down the list… 


Robert

unread,
Jul 18, 2021, 3:18:35 PM7/18/21
to Kivy users support
Thanks. Good suggestion.

Elliot Garbus

unread,
Jul 18, 2021, 3:46:26 PM7/18/21
to kivy-...@googlegroups.com
It looks like you are only checking for ’scroll' https://github.com/Android-for-Python/Common-Gestures-Example/blob/7b3728da2bf21481614750a90a4dea12bd1ed8de/commongestures.py#L66
There are 4 mouse scroll events: ['scrollup', 'scrolldown', 'scrollleft','scrollright']

On the Mac trackpad, these events are tied to a 2 finger gesture.  On the Mac mouse, dragging a finger across the mouse causes these events.
On a Windows PC mouse with a scroll wheel, if the wheel can be tipped left or right, it will create the scroll left and scroll right messages.


Robert

unread,
Jul 18, 2021, 4:44:39 PM7/18/21
to Kivy users support
Great stuff Elliot, new ways to do shift-wheel. Prototype attached (assumes the GH version with shift-wheel support)

What is the Mac sideways scroll gesture? I can't find it here https://support.apple.com/en-us/HT204895
commongestures.py

ElliotG

unread,
Jul 18, 2021, 5:05:28 PM7/18/21
to Kivy users support
On the Mac touchpad a sideways scroll is 2 fingers left or right.  On the mouse it is dragging a finger across the mouse, left or right.

Doing some experiments on the Mac and the PC kivy does not create events for a pinch/zoom gesture.  I used a scatter widget on my pc with a touch screen - I can pinch and zoom on the screen - but not the touchpad.  To pinch and zoom on the touchpad, I need to use the red dot.

Reply all
Reply to author
Forward
0 new messages