Difference between revisions of "Event"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Supported platforms</translate>:''' [[File:Platform android]][[File:Platform ios]][[File:Platform mac]][[File:Platform pc]]<br/>
+
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/>
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
The objects of `Event` class contains information about an event that has occurred. `Event` objects<br />
+
The objects of [[Special:MyLanguage/Event|Event]] class contains information about an event that has occurred. [[Special:MyLanguage/Event|Event]] objects<br />
 
are passed to event listeners when an event occurs.<br />
 
are passed to event listeners when an event occurs.<br />
 
<br />
 
<br />
 
Usually event objects contains specific additional information about the event that has occured. For example,<br />
 
Usually event objects contains specific additional information about the event that has occured. For example,<br />
when an `Event.MOUSE_DOWN` event occurs, `x` and `y` fields contain the coordinates.<br />
+
when an [[Special:MyLanguage/Event.MOUSE_DOWN|Event.MOUSE_DOWN]] event occurs, ''x'' and ''y'' fields contain the coordinates.<br />
 
Users can create their own events and dispatch through the event mechanism.<br /></translate>
 
Users can create their own events and dispatch through the event mechanism.<br /></translate>
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===

Revision as of 09:36, 24 August 2018

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

Description


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.

Examples

Mouse down event example

function onMouseDown(event)
	print(event.x, event.y)
end
mysprite:addEventListener(Event.MOUSE_DOWN, onMouseDown)

User created event

local event = Event.new(&quot;myevent&quot;)
event.data1 = &quot;12345&quot;
event.data2 = &quot;abcde&quot;
mydispatcher:dispatchEvent(event)

Methods

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

Events

Constants