Tk Source Code

View Ticket
Login
Ticket UUID: 9c2f8da61129bb2c0b91e58bbfd317c2f5e4347e
Title: Handling simple touch events
Type: RFE Version: 8.7
Submitter: anonymous Created on: 2014-08-21 22:53:14
Subsystem: 01. Bindings Assigned To: oehhar
Priority: 7 High Severity: Severe
Status: Open Last Modified: 2020-03-18 16:01:33
Resolution: None Closed By: nobody
    Closed on:
Description:
Feature request:

Under a windows 8 tablet, or any other touch-enabled device, it is impossible to listen for and handle touch events from the user, such as a pinch to make smaller/bigger, or perhaps swipe left/right.
The request is to provide bindings to handle these simple touch events.
User Comments: oehhar added on 2020-03-18 16:01:33:

Tip 570 is started:

https://core.tcl-lang.org/tips/doc/trunk/tip/570.md

There is not much useful information in.

I personally only have the requirements for scroll and zoom. Due to that, only those are elaborated.

Please feel free to enhance the document.

I feel, it is a long way, but without a start we will never end.

Thank you, Harald


oehhar added on 2020-03-17 10:18:46:

Dear Christoph,

thank you for the initiative. I am also very interested in this feature.

The right place to discuss is within a TIP. Do you have commit right on https://core.tcl-lang.org/tips ?

If not, please contact Andreas Kupries to get it.

I am ready to setup an initial TIP.

Thank you, Harald


chrstphrchvz added on 2020-03-17 09:59:30:

Similar feature support has been requested for Aqua ([270b0aedd4]) and should also be possible on X11 ([27fc8b7820]).

If this is to be implemented, I would much rather see support for all platforms arrive simultaneously in one release, rather than multiple releases over time.

Would it be a good idea to designate a single ticket for this feature on all platforms?


oehhar added on 2016-08-22 05:46:30:

I would really enjoy that.

Androwish already has the event <<PinchToZoom>>.

http://www.androwish.org/index.html/wiki?name=sdltk+command

I suppose, Christian may be helpful to implement that in a generic manner.


pspjuth added on 2016-08-13 20:01:02:
An experimental touch/gesture implementation is now in the pspjuth-touch branch.

We should know more how other platforms might do it
so at least the script API is reasonably forward compatible.

dkf added on 2014-08-22 21:15:09:

This was in relation to this question on StackOverflow. The issue is that we don't handle events in anything like the same way as the standard model applications do; we're not a C++ (or C# or VB.NET) application. It requires someone who knows the Win event model well and who has a touch-enabled device with Win8 on it to put a hack into our code that maps Win events to "X11" events (well, to our extensions of them) and print out the content of events that we don't handle right now. Like that, we'd be able to find out what the messages actually are.

Assuming that they're ordinary messages and not something else.

We also need to investigate to find out how such events are handled by X11, if at all. If they're not, we can just make our own events, no problem, but if they are, we should follow that model, at least for event naming.

At least the contents of the events seem sensible.


Stack Overflow Q

How would I go about installing a handler of touchscreen gestures in Tkinter?

I need to something particularly simple: to increase the font size whenever an 'expand' gesture is detected.

Is this even possible to do in Tkinter if Tcl/Tk doesn't specifically implement it? I suppose that either the window manager sends the client window some event that I could listen for and handle, or the client must register to the window manager a handler for a specific kind of event, but if it isn't possible to register these handlers from Tkinter and if Tcl doesn't provide an interface to them, I'm don't see a way I could do this.

Stack Overflow A

Tk doesn't support the complex touch events at the moment, and MSDN is very thin on what they actually look like when they come in over the event loop. (It's not something that you're supposed to look at, it seems.) Because Tk intercepts that data at a very low level, it's going to be tricky to integrate.

I can't chase this further. I can see how some of the code works, but way that the samples on MSDN function doesn't match up at all to what Tk's doing. There's a whole framework's worth of mismatch between the two. (I also don't have a device which would support these features; my touch devices don't run Windows and my Windows devices don't support touch input.)

What we would need is someone with a touch-input Win 8 system to run a Tk app that has been hacked (Tk_TranslateWinEvent() in win/tkWinX.c would be the right spot) to print out unrecognised events. We could then see what actually comes over the wire (well, through the master message pump) with touch events; we might hope that they correspond to things involved in the ManipulationStarted, ManipulationUpdated and ManipulationCompleted events, but hope is not always enough. (We might also hope that the events aren't squirrelled in via another route.)


Key Resources

ManipulationUpdatedEventArgs (type of payload of event, but might also have info about which window to deliver the event to, which is eaten by the framework in the examples on MSDN)
PropertyAccess typeDescription

Cumulative

Read-onlyGets values that indicate the accumulated transformation deltas (translation, rotation, scale) for a manipulation from the beginning of the interaction to the ManipulationUpdated event.

Delta

Read-onlyGets values that indicate the changes in the transformation deltas (translation, rotation, scale) of a manipulation since the last manipulation event.

PointerDeviceType

Read-onlyGets the device type of the input source.

Position

Read-onlyGets the location of the pointer associated with the manipulation for the last manipulation event.

Velocities

Read-onlyGets values that indicate the velocities of the transformation deltas (translation, rotation, scale) for a manipulation at the ManipulationUpdated event.
ManipulationDelta (type of Cumulative and Delta properties)
FieldData typeDescription
Expansion | expansion

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The change in distance between touch contacts, as DIPs. For example, if the distance between two contacts changes from 100 DIPs to 200 DIPs during a manipulation, the value of Expansion would be 100.0.

Rotation | rotation

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The change in angle of rotation, in degrees.

Scale | scale

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The change in distance between touch contacts, as a percentage. For example, if the distance between two contacts changes from 100 DIPs to 200 DIPs during a manipulation, the value of Scale would be 1.0.

Translation | translation

Point

The change in x-y screen coordinates, in DIPs.

ManipulationVelocities (type of Velocities property)
FieldData typeDescription
Angular | angular

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The rotational velocity in degrees per millisecond.

Expansion | expansion

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The expansion, or scaling, velocity in DIPs per millisecond.

Linear | linear

Point

The straight line velocity in DIPs per millisecond.