Difference between revisions of "EventDispatcher"
(Created page with "__NOTOC__ '''Supported platforms:''' <br/> '''Available since:''' Gideros 2011.6<br/> === Description === <br /> All classes that dispatch events inherit from `EventDispatcher...") |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Supported platforms:''' <br/> | + | '''Supported platforms:''' android, ios, mac, pc<br/> |
'''Available since:''' Gideros 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
=== Description === | === Description === | ||
Line 10: | Line 10: | ||
On the other hand, `Event.ENTER_FRAME` event is dispatched to all `Sprite` objects.<br /> | On the other hand, `Event.ENTER_FRAME` event is dispatched to all `Sprite` objects.<br /> | ||
<br /> | <br /> | ||
− | If you want to define a class that dispatches events, you can inherit your class from `EventDispatcher`.<br />{|- | + | If you want to define a class that dispatches events, you can inherit your class from `EventDispatcher`.<br /> |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | {|- | ||
| style="width: 50%;"| | | style="width: 50%;"| | ||
=== Methods === | === Methods === | ||
+ | [[EventDispatcher.new]] - creates a new EventDispatcher object<br/> | ||
+ | [[EventDispatcher:addEventListener]] - registers a listener function<br/> | ||
+ | [[EventDispatcher:dispatchEvent]] - dispatches an event<br/> | ||
+ | [[EventDispatcher:hasEventListener]] - checks if the EventDispatcher object has a event listener<br/> | ||
+ | [[EventDispatcher:removeAllListeners]] - remove all listeners<br/> | ||
+ | [[EventDispatcher:removeEventListener]] - removes a listener function<br/> | ||
| style="width: 50%;"| | | style="width: 50%;"| | ||
=== Events === | === Events === | ||
+ | [[Event.APPLICATION_BACKGROUND]] | ||
+ | [[Event.APPLICATION_EXIT]] | ||
+ | [[Event.APPLICATION_FOREGROUND]] | ||
+ | [[Event.APPLICATION_RESIZE]] | ||
+ | [[Event.APPLICATION_RESUME]] | ||
+ | [[Event.APPLICATION_START]] | ||
+ | [[Event.APPLICATION_SUSPEND]] | ||
+ | [[Event.MEMORY_WARNING]] | ||
+ | [[Event.OPEN_URL]] | ||
=== Constants === | === Constants === | ||
|} | |} |
Revision as of 08:57, 23 August 2018
Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6
Description
All classes that dispatch events inherit from `EventDispatcher`. The target of an event is a listener function and an optional data value.
When an event is dispatched, the registered function is called.
If the optional data value is given, it is used as a first parameter while calling the listener function.
Event dispatching and event targets are the core part of the Gideros event model. Different event types (such as `Event.ENTER_FRAME`, `Event.TOUCHES_BEGIN` or `Event.MOUSE_DOWN`) flow through the scene tree hierarchy differently. When a touch or mouse event occurs, Gideros dispatches an event object into the event flow from the root of the scene tree.
On the other hand, `Event.ENTER_FRAME` event is dispatched to all `Sprite` objects.
If you want to define a class that dispatches events, you can inherit your class from `EventDispatcher`.
MethodsEventDispatcher.new - creates a new EventDispatcher object |
EventsEvent.APPLICATION_BACKGROUND Event.APPLICATION_EXIT Event.APPLICATION_FOREGROUND Event.APPLICATION_RESIZE Event.APPLICATION_RESUME Event.APPLICATION_START Event.APPLICATION_SUSPEND Event.MEMORY_WARNING Event.OPEN_URL Constants |