Object
zEventTarget
The zEventTarget
class is based on the DOM
EventTarget
interface and is used to provide registration and removal of event listeners
on an object and to dispatch of events to that object. This class is not intended to be used by itself, but
rather as a superclass for objects needing to support events.
Nicholas C. Zakas, http://www.nczonline.net/
1.0
1.0
zEventTarget() Creates a new instance of zEventTarget . |
void |
addEventListener(String type, Function handler) Adds an event handler for the given type of event. |
boolean |
dispatchEvent(zEvent event) Fires an event on the zEventTarget and provides the zEvent
object for contextual information about the event. |
void |
removeEventListener(String type, Function handler) Removes an event handler for the given type of event. |
public zEventTarget()
Creates a new instance of zEventTarget
.
public void addEventListener(String type, Function handler)
Adds an event handler for the given type
of event.
type
- the type of event to register the handler for.handler
- a function to call when the event occurs.public boolean dispatchEvent(zEvent event)
Fires an event on the zEventTarget
and provides the zEvent
object for contextual information about the event.
event
- the zEvent object containing
information about the event to fire.True if the default event action should take place, false if not.
public void removeEventListener(String type, Function handler)
Removes an event handler for the given type
of event.
type
- the type of event to remove the handler from.handler
- the function to remove.