Tap Events
Do you want to execute code when the user first touches or clicks the node? Or, do you want to execute code only after the user releases the touch or click? You can do this with the onTapDown()
and onTapUp()
methods.
onTapUp()
occurs only when the user releases a touch or click within the bounds of the node. You may or may not want this restriction. For example, users with less dexterity might have trouble releasing a touch or click within the bounds of the node. If you want to execute code when the user releases a touch or click anywhere, use the onTapUpAny()
method.
To understand the difference between onTapUp()
and onTapUpAny()
, click the "I respond to TapUp" button, but move your mouse or finger outside the bounds of the button before releasing the touch or click. You'll see that the button does not respond to the event. Then, click the "I respond to TapUpAny" button, and move your mouse or finger outside the bounds of the button before releasing the touch or click. You'll see that the button responds to the event.
- A node can respond to multiple events. See how the button responds to
TapDown
,TapUp
, andTapLeave
.