Skip to main content

Event Properties

Events have properties that describe the event.

In the event handler code for an event, you know what event has occurred. For example, if you are handling a TapDown event, you know that the user has tapped down on the node. But what if you need to know where the user tapped down?

The Tap and Pointer events all contain these additional properties:

  • point - the point on the node where the event occurred.
  • buttons - the buttons that were pressed when the event occurred.
  • type - the type of event that occurred, as a string, such as TapDown or PointerMove.
  • target - the node on which the event occurred.1
  • handled - a boolean value that indicates whether the event has been handled. If the event has been handled, then the event will not be passed to any other nodes. This is useful for preventing the event from being handled by multiple nodes.
note

The event's point property is the most useful Tap and Pointer event property. The others are for more advanced scenarios.

The below example prints where on the button the user tapped down. To access the event properties, you provide a variable to represent the event in the event handler code. The variable name can be anything you want, but by convention it is common to use the name e, ev, or event.

Loading...
Explore:
  • A more advanced example: use a single event handler, called buttonEventHandler() for different buttons and events. Examine the event's type property to know which event occurred and the target property to know which button had the event.

Footnotes

  1. target is similar to the concept of sender in C# event handling and the object returned by EventObject.getSource() in Java.