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.

Details

  • 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 {0,0} is taken to be at the bottom left.
  • For complete windows and documents, {0,0} is taken to be at the top left.
  • For the complete screen display, {0,0} 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 "Graphics", 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"}].`

Examples

Basic Examples  (2)

Get the current positions being touched:

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

Get the dynamically updated touch positions:

Wolfram Research (2014), TouchPosition, Wolfram Language function, https://reference.wolfram.com/language/ref/TouchPosition.html.

Text

Wolfram Research (2014), TouchPosition, Wolfram Language function, https://reference.wolfram.com/language/ref/TouchPosition.html.

CMS

Wolfram Language. 2014. "TouchPosition." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TouchPosition.html.

APA

Wolfram Language. (2014). TouchPosition. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TouchPosition.html

BibTeX

@misc{reference.wolfram_2023_touchposition, author="Wolfram Research", title="{TouchPosition}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/TouchPosition.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_touchposition, organization={Wolfram Research}, title={TouchPosition}, year={2014}, url={https://reference.wolfram.com/language/ref/TouchPosition.html}, note=[Accessed: 19-March-2024 ]}