Difference between revisions of "Event"

(Undo revision 13675 by MoKaLux (talk))
(Tag: Undo)
Line 38: Line 38:
=== <translate>Constants</translate> ===
=== <translate>Constants</translate> ===

Revision as of 13:00, 4 December 2019

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: Object


The objects of Event class contains information about an event that has occurred. Event objects
are passed to event listeners when an event occurs.

Usually event objects contains specific additional information about the event that has occured. For example,
when an Event.MOUSE_DOWN event occurs, x and y fields contain the coordinates.
Users can create their own events and dispatch through the event mechanism.


Mouse down event example

function onMouseDown(event)
  print(event.x, event.y)

mysprite:addEventListener(Event.MOUSE_DOWN, onMouseDown)

User created event

local event = Event.new("myevent")
event.data1 = "12345"
event.data2 = "abcde"


Event.new creates a new Event object
Event:getTarget returns the element on which the event listener was registered
Event:getType returns the type of Event
Event:stopPropagation stops the propagation of the current event in the scene tree hierarchy