Record TTouch

Hierarchy
Methods
Properties

Unit

Declaration

type TTouch = record

Description

Tracking of a touch by a single finger, used by TTouchList.

Overview

Fields

Public FingerIndex: TFingerIndex;
Public Position: TVector2;

Description

Fields

Public FingerIndex: TFingerIndex;

Index of the finger/mouse. Always simply zero on traditional desktops with just a single mouse device. For devices with multi-touch (and/or possible multiple mouse pointers) this is actually useful to connect touches from different frames into a single move action. In other words: the FinderIndex stays constant while user moves a finger over a touch device.

All the touches on a TCastleContainer.Touches array always have different FingerIndex value.

Note that the index of TTouch structure in TCastleContainer.Touches array is not necessarily equal to the FingerIndex. It cannot be — imagine you press 1st finger, then press 2nd finger, then let go of the 1st finger. The FingerIndex of the 2nd finger cannot change (to keep events sensibly reporting the same touch), so there has to be a temporary "hole" in FinderIndex numeration.

Public Position: TVector2;

Position of the touch over a device.

Position (0, 0) is the window's bottom-left corner. This is consistent with how our 2D controls (TCastleUserInterface) treat all positions.

The position is expressed as a float value, to support backends that can report positions with sub-pixel accuracy. For example GTK and Android can do it, although it depends on underlying hardware capabilities as well. The top-right corner or the top-right pixel has the coordinates (Width, Height). Note that if you want to actually draw something at the window's edge (for example, paint the top-right pixel of the window with some color), then the pixel coordinates are (Width - 1, Height - 1). The idea is that the whole top-right pixel is an area starting in (Width - 1, Height - 1) and ending in (Width, Height).

Note that we have mouse capturing (when user presses and holds the mouse button, all the following mouse events are reported to this window, even when user moves the mouse outside of the window). This is typical of all window libraries (GTK, LCL etc.). This implicates that mouse positions are sometimes tracked also when mouse is outside the window, which means that mouse position may be outside the rectangle (0, 0) - (Width, Height), so it may even be negative.


Generated by PasDoc 0.16.0-snapshot.