PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TouchLongPress

The TouchLongPress event fires after a brief moment when the player holds their finger on the UI element using a touch-enabled device. It fires with a table of DataType/Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires multiple times with multiple Enum/UserInputStates: Begin after a brief delay, Change if the player moves their finger during the gesture and finally with End. The delay is platform dependent; in Studio it is a little longer than one second.

Since this event only requires one finger, this event can be simulated in Studio using the emulator and a mouse. Below is an example of TouchLongPress firing on a Frame that is GuiObject/Active. Below, the event fires after a brief delay (Begin) and then continually as as the finger is moved (Change). It fires one last time after it is released (End).

TouchLongPress gesture

This event is part of a family of touch-related events. Other events like this one are GuiObject/TouchTap, GuiObject/TouchRotate, GuiObject/TouchPinch, GuiObject/TouchPan and GuiObject/TouchSwipe. In addition, UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService/TouchLongPress.

Parameters

Name Type Default Description

An array of DataType/Vector2 that describe the relative positions of the fingers involved in the gesture.

A Enum/UserInputState that describes the state of the gesture:

  • Begin fires once at the beginning of the gesture (after the brief delay)
  • Change fires if the player moves their finger while pressing down
  • End fires once at the end of the gesture when they release their finger

Code Samples


Move UI Element with TouchLongPress

This code sample allows the player to manipulate the screen position of some UI element, like a Frame, by holding down on the UI element for a brief moment. Then, the player moves their finger and releases. During the gesture the Frame is colored blue with a white outline.