Difference between revisions of "Event"

From GiderosMobile
Line 2: Line 2:
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
=== Description ===
+
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
 
The objects of [[Special:MyLanguage/Event|Event]] class contains information about an event that has occurred. [[Special:MyLanguage/Event|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 />
Line 10: Line 10:
 
when an [[Special:MyLanguage/Event.MOUSE_DOWN|Event.MOUSE_DOWN]] event occurs, [[Special:MyLanguage/x|x]] and [[Special:MyLanguage/y|y]] fields contain the coordinates.<br />
 
when an [[Special:MyLanguage/Event.MOUSE_DOWN|Event.MOUSE_DOWN]] event occurs, [[Special:MyLanguage/x|x]] and [[Special:MyLanguage/y|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>
=== Examples ===
+
=== <translate>Examples</translate> ===
 
'''Mouse down event example'''<br/>
 
'''Mouse down event example'''<br/>
 
<source lang="lua">function onMouseDown(event)
 
<source lang="lua">function onMouseDown(event)
Line 23: Line 23:
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Methods ===
+
=== <translate>Methods</translate> ===
 
[[Special:MyLanguage/Event.new|Event.new]] ''<translate>creates a new Event object</translate>''<br/>
 
[[Special:MyLanguage/Event.new|Event.new]] ''<translate>creates a new Event object</translate>''<br/>
 
[[Special:MyLanguage/Event:getTarget|Event:getTarget]] ''<translate>returns the element on which the event listener was registered</translate>''<br/>
 
[[Special:MyLanguage/Event:getTarget|Event:getTarget]] ''<translate>returns the element on which the event listener was registered</translate>''<br/>
Line 29: Line 29:
 
[[Special:MyLanguage/Event:stopPropagation|Event:stopPropagation]] ''<translate>stops the propagation of the current event in the scene tree hierarchy</translate>''<br/>
 
[[Special:MyLanguage/Event:stopPropagation|Event:stopPropagation]] ''<translate>stops the propagation of the current event in the scene tree hierarchy</translate>''<br/>
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Events ===
+
=== <translate>Events</translate> ===
=== Constants ===
+
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 07:28, 24 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6

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