Author: Harald Oehlmann <[email protected]>
State: Draft
Type: Project
Vote: Pending
Created: 18-Mar-2020
Post-History:
Keywords: Tk, bindings
Tcl-Version: 9.0
Tk-Branch: pspjuth-touch
Abstract
Support for the gestures "finger scroll" and "pinch to zoom" are proposed in a platform neutral way.
NB: This tip is not ready specified yet. Anybody is invited to contribute.
Specification
Overview
Many systems (e.g. Windows, Linux Window Manager, Mac-OS, Android) nowdays support gestures in a generic manner. The gestures may be different and the input media may be different. Possible input media are a touch-screen or a touchpad.
The aim of this TIP is to make gestures provided by the system available within Tk.
The targeted gestures are:
- scrolling, for example by pointing two fingers on the touch-screen and moving it. This is often identical to the pan gesture.
- zooming, for example by pinching two fingers on a touch-screen.
There is a direct relation to the displayed image if a touch-screen is used. The scroll gesture gives a source and target point on the screen.
Platforms
The following discussion is about possible implementations on different platforms
Windows
Peter Spjuth has authored a Windows implementation in tk.branch pspjuth-touch
The two gestures are implemented by the following virtual bind tags:
- Zoom:
<<PinchToZoom>>
with substitutions%W %d %x %y %X %Y
%W
: Window (below the fingers)%d
: descriptive dict (gesture=zoom, distance=finger distance)%x,%y
: position.
- Scroll:
<<Gesture>>
with substitutions%W %d %x %y %X %Y
%W
: Window (below the fingers)%d
: descriptive dict (gesture=pan, distance=finger distance > 0 for two fingers)%x,%y
: position
AndroWish
Christian Werner has defined the following virtual binding tags. This information is copied and adapted from the Androwish documentation.
Zoom:
<<PinchToZoom>>
with substitutions%X %Y %x %y %s
%X
and%Y
are substituted with the root window coordinate of the center of the two fingers%x
with the distance between the two fingers%y
with the angle measured in 64 times degrees CCW starting at 3 o'clock.%s
is the finger state:0
(zoom motion),1
(zoom start, i.e. 2nd finger down event),2
(zoom end by 1st finger up event),3
(zoom end by 2nd finger up event)
Scroll:
<<FingerDown>>
,<<FingerUp>>
,<<FingerMotion>>
Scrolling by two fingers may be implemented by observing those events. The following substitutions are supported for all these three finger-related events:
%x
and%y
are the finger position scaled to {0...9999} of the device screen or viewport%X
and%Y
are the motion difference scaled to {-9999...+9999}%t
is the pressure scaled to {0...9999}, and%s
is the finger identifier {1...10}
Linux
Mac-OS
Rationale
Implementation
The following fragments are known:
- tk.branch pspjuth-touch
- AndroWish
Discussion
Copyright
This document has been placed in the public domain.