TouchPosition

TouchPosition[]
gives the list of current positions being touched in the notebook front end.

TouchPosition["coords"]
gives the touch positions with respect to the specified coordinate system.

TouchPosition["coords",n]
gives the position of the n^(th) position being touched in an object in the specified coordinate system.

TouchPosition["coords",n,def]
returns def if there are not n positions being touched.

DetailsDetails

  • TouchPosition is only active on touchscreen devices. Otherwise, it acts as an inert wrapper.
  • Dynamic[TouchPosition[]] gives the continually updated current touch positions.
  • TouchPosition[{"coords",h}] takes the coordinate system to extend only over the contents of the nearest enclosing object with head h.
  • The following coordinate systems can be used:
  • "ScreenAbsolute"absolute position within the complete screen display
    "ScreenScaled"scaled position within the complete screen display
    "WindowAbsolute"absolute position down the current window
    "WindowScaled"scaled position down the current window
    "DocumentAbsolute"absolute position down the current complete document
    "DocumentScaled"scaled position down the current complete document
    "CellAbsolute"absolute position within the current cell
    "CellScaled"scaled position within the current cell
    "CellContentsAbsolute"absolute position within the content area of the current cell
    "CellContentsScaled"scaled position within the content area of the current cell
    "EventHandlerAbsolute"absolute position within the current event handler region
    "EventHandlerScaled"scaled position within the current event handler region
    "Graphics"coordinates in the current graphic
    "Graphics3DBoxIntercepts"front and back intercepts with the 3D bounding box
    "GraphicsAbsolute"absolute position within the current graphic
    "GraphicsScaled"scaled position within the current graphic
    "GraphicsImageScaled"scaled position within the current graphics image area
  • Absolute positions are given in printer's points, corresponding to pixels on 72 dpi displays.
  • Scaled positions normally run from 0 to 1 in each direction.
  • For constructs that appear within windows, position is taken to be at the bottom left.
  • For complete windows and documents, is taken to be at the top left.
  • For the complete screen display, is taken to be at the top-left corner of the primary monitor. Secondary monitors correspond to scaled positions outside the range 0 to 1.
  • For , ordinary coordinates as specified by PlotRange are used.
  • TouchPosition["coords",All,def] returns def if there are no touches.
  • TouchPosition["coords",n, def] returns the coordinate of the n^(th) touch, or def if there are not n touches. For n=1, the oldest touch is returned. Larger values of n select more recently added touches.
  • TouchPosition["coords"] is equivalent to TouchPosition["coords",All,None], so that by default None is returned if there are no touches on an object that defines the specified coordinate system.
  • TouchPosition["coords"] is equivalent to CurrentValue[{"TouchPosition","coords"}].`

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Get the current positions being touched:

In[1]:=
Click for copyable input
Out[1]=

Output when no positions are touched, or on a non-touch platform:

In[2]:=
Click for copyable input
Out[2]=

Get the dynamically updated touch positions:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)