Difference between revisions of "Event"
m |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | |||
<!-- GIDEROSOBJ:Event --> | <!-- GIDEROSOBJ:Event --> | ||
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | ||
Line 6: | Line 5: | ||
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/> | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/> | ||
− | === | + | === Description === |
− | The objects of | + | The objects of '''Event''' class contain 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 [[Special:MyLanguage/Event.MOUSE_DOWN|Event.MOUSE_DOWN]] event occurs, ''x'' and ''y'' fields contain the coordinates. | Usually event objects contains specific additional information about the event that has occured. For example, when an [[Special:MyLanguage/Event.MOUSE_DOWN|Event.MOUSE_DOWN]] event occurs, ''x'' and ''y'' fields contain the coordinates. | ||
Line 13: | Line 12: | ||
Users can create their own events and dispatch through the event mechanism. | Users can create their own events and dispatch through the event mechanism. | ||
− | === | + | === Examples === |
'''Mouse down event example''' | '''Mouse down event example''' | ||
<source lang="lua"> | <source lang="lua"> |
Revision as of 23:21, 25 March 2020
Supported platforms:
Available since: Gideros 2011.6
Inherits from: Object
Description
The objects of Event class contain 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("myevent")
event.data1 = "12345"
event.data2 = "abcde"
mydispatcher:dispatchEvent(event)
MethodsEvent.new creates a new Event object Event:getTarget returns the element on which the event listener was registered |
EventsConstants |