Skip to content

Gestures

Introduction

Gestures are user interactions that are most commonly generated by touching and moving fingers on the screen, although other means (for example, touch pad, stylus) can be used to perform the same operations.

The following Gestures are supported by Dyalog APL:

Gesture Description
Pan The user touches one or two fingers on the screen and drags or swipes them.
Zoom The user touches two fingers on the screen and moves them towards each other (zoom out) or away from each other (zoom in).
Rotate The user touches two fingers on the screen and then twists them as if turning a knob.
Tap The user taps (touches briefly) one or two fingers on the screen.
Press and Tap The user presses one finger on the screen, then taps the screen with a second finger, while the first finger remains in contact with the screen.

Gesture Events

Gestures generate GUI events, which are summarised in the table below.

Apart from GestureTwoFingerTap, which generates a single event, Gestures generate a series of events of the same type. The first of these is flagged as a starting event. Then there are a series of one or more continuation events, followed finally by one that is flagged as the final event in the series. Each series consists of events of the same type and no other type of event will be reported between the start and end of that series.

Event Description
GesturePan One or more of these events are generated by a Pan Gesture.
GestureRotate One or more of these events are generated by a Rotate Gesture.
GestureZoom One or more of these events are generated by a Zoom Gesture.
GesturePressAndTap This event is generated by a Press and Tap Gesture.
GestureTwoFingerTap This event is generated by a Tap Gesture using two fingers.

Handling Gestures

Gestures do not in themselves do anything by default, but if left unhandled, may generate other events which do do something by default. For example, an unhandled Pan Gesture on a scrollbar will, by default, cause it to scroll.

An application can choose to handle Gesture events in a specifically application-dependent manner or choose to ignore them, relying on objects to respond to mouse or scroll events (which are generated by unhandled Gesture events) as appropriate.

In Dyalog APL, a Gesture event is handled by attaching a callback function which responds to the event in some way. The result of the callback function is important. The value 0 tells the Operating System that the application has handled (consumed) the event and instructs Windows NOT to take any further action. The value 1 means that the application has not taken action and instructs Windows to do whatever it would normally do in response to the Gesture; for example, to treat it as a mouse or scroll operation.

If you attach a callback to the GesturePan event which responds by, for example, moving the object, the callback should return 0. See also: High-Priority Callback Functions.

Inertia

When a Pan gesture is made, the operating system may generate additional GesturePan events depending upon the speed with which the Gesture has been made. For example, if the user makes a short but rapid swiping motion with a finger, inertia generates GesturePan events over a greater distance than the finger was actually in contact with the screen. Information as to whether or not the event was generated by inertia is provided in the event message.