Class Index | File Index

## Classes

- _global_
- Array
- Function
- pockets
- pockets.managers
- pockets.managers.EventManager
- pockets.managers.EventRegistration
- pockets.managers.EventTargetRegistration
- pockets.managers.MenuManager

# Class pockets.managers.EventManager

EventManager is helper class for Mojo Scene Assistants, implementing a registry of events. It handles registration of both DOM events (using EventManager#register) and custom events (using EventManager#registerEventTarget). EventManager#startAllListening will start listening to all registered events and EventManager#stopAllListening will stop listening to all registered Events. These calls should be used in your scene assistant's #activate & #deactivate methods in order to minimize memory usage/leaks. EventManager also tracks the Mojo.event.onStageDeactivate (app minimize) and Mojo.event.onStageActivate (app maximixe) events and calls SceneAssistant#onStageDeactivate and SceneAssistant#onStageActivate and the EventManager will call them. Recommended behavior is, at minimum, for a Scene Assistant to call SceneAssistant#deactivate & SceneAssistant#activate respectively. TODO: - examples - explain/deprecate the takeoverActivateMethods flag and ALWAYS act as proxy for activate/deactivate/clearnup By passing in a true Boolean, EventManager will take over your scene All events registered in the EventManager will be removed when the Scene is deactivated,
Defined in: pockets-managers.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| pockets.managers.EventManager(assistant, takeoverActivateMethods)

Method Summary
Method Attributes | Method Name and Description
--- | ---
| cleanup() Cleans up after itself.
| register(element, trigger, handler) Registers an Event handler for a DOM Element.
| registerEventTarget(eventTarget, trigger, handler) Registers an Event handler for a non-DOM Element class.
| startAllListening() Starts listening for all currently registered events.
| stopAllListening() Stops listening for all currently registered events.
| unregister(eventRegistration) Removes an event Registration from the collection of events.

Class Detail
pockets.managers.EventManager(assistant, takeoverActivateMethods)

Parameters:
assistant
  {Function} a Mojo Scene Assistant
takeoverActivateMethods
  {true|false}

Method Detail
cleanup()
Cleans up after itself.

{pockets.managers.EventRegistration} register(element, trigger, handler)
Registers an Event handler for a DOM Element. If the scene is active, the EventManager will start listening for that event.

Parameters:
element
  {Element|String} DOM Element or string representing the id attribute of a DOM Element that will receive the event
trigger
  {Event} event
handler
  {Function} handler function to call when the event is caught/heard

Returns:
  {pockets.managers.EventRegistration} the event registration, in case this needs to be unregistered

{pockets.managers.EventRegistration} registerEventTarget(eventTarget, trigger, handler)
Registers an Event handler for a non-DOM Element class. If the scene is active, the EventManager will start listening for that event.

Parameters:
eventTarget
  {pockets.EventTarget} instance of a class that will fire the event, must be a child class of pockets.EventTarget
trigger
  {Event} event
handler
  {Function} handler function to call when the event is caught/heard

Returns:
  {pockets.managers.EventRegistration} the event registration, in case this needs to be unregistered

startAllListening()
Starts listening for all currently registered events. Also starts listening for Mojo.Event.stageDeactivate.

stopAllListening()
Stops listening for all currently registered events.

unregister(eventRegistration)
Removes an event Registration from the collection of events. Subsequent calls to EventManager#startAllListening will not reinstall this handler. If the scene is active, and thus the event is registered, it will stop listening.

Parameters:
eventRegistration

Documentation generated by JsDoc Toolkit 2.3.0 on Sat Jun 27 2009 08:38:33 GMT-0700 (PDT)