GestureScope
Deprecated Replaced by TouchInjectionScope
class GestureScope(node: SemanticsNode, testContext: TestContext)
The receiver scope for injecting gestures on the SemanticsNode identified by the corresponding
SemanticsNodeInteraction
. Gestures can be injected by calling methods defined on
GestureScope
, such as click
or swipe
. The SemanticsNodeInteraction
can be found by one of
the finder methods such as
onNode
.
The functions in GestureScope
can roughly be divided into two groups: full gestures and
individual touch events. The individual touch events are: down
, move
and friends, up
,
cancel
and advanceEventTime
. Full gestures are all the other functions, like click
,
doubleClick
, swipe
, etc. See the documentation of down
for more information about
individual events. If you execute a full gesture while in the middle of another gesture, an
IllegalStateException
or IllegalArgumentException
can be thrown when the pointerId is
unintentionally used for both gestures. If you want to perform e.g. a click during a partially
performed gesture, make sure they use different pointer ids.
Note that all events generated by the gesture methods are batched together and sent as a whole
after performGesture
has executed its code block.
Next to the functions, GestureScope
also exposes several properties that allow you to get
coordinates
within a node, like the top left corner
, its center
, or some
percentage of the size (percentOffset
).
Example of performing a click:
Example of performing a swipe up:
Example of performing an L-shaped gesture:
Properties
val visibleSize: IntSize
Returns the size of the visible part of the node we're interacting with. This is contrary to
SemanticsNode.size
, which returns the unclipped size of the node.