Class Index | File Index

Classes


Class glow.events.Event


Defined in: core.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
glow.events.Event(properties)
Describes an event that occurred.
Field Summary
Field Attributes Field Name and Description
 
The object the listener was attached to.
 
The actual object/element that the event originated from.
Method Summary
Method Attributes Method Name and Description
 
Has the default been prevented for this event? This should be used by whatever fires the event to determine if it should carry out of the default action.
 
Prevent the default action of the event.
Class Detail
glow.events.Event(properties)
Describes an event that occurred. You don't need to create instances of this class if you're simply listening to events. One will be provided as the first argument in your callback.
		// creating a simple event object
		var event = new glow.events.Event({
			velocity: 50,
			direction: 180
		});
		       
		// 'velocity' and 'direction' are simple made-up properties
		// you may want to add to your event object
		// inheriting from glow.events.Event to make a more
		// specialised event object
		       
		function RocketEvent() {
			// ...
		}
		       
		// inherit from glow.events.Event
		glow.util.extend(RocketEvent, glow.events.Event, {
			getVector: function() {
				return // ...
			}
		});
		       
		// firing the event
		rocketInstance.fire( 'landingGearDown', new RocketEvent() );
		       
		// how a user would listen to the event
		rocketInstance.on('landingGearDown', function(rocketEvent) {
			var vector = rocketEvent.getVector();
		});
Parameters:
{Object} properties Optional
Properties to add to the Event instance. Each key-value pair in the object will be added to the Event as properties.
Field Detail
attachedTo
The object the listener was attached to. If null, this value will be populated by glow.events.Target#fire

{Element} source
The actual object/element that the event originated from. For example, you could attach a listener to an 'ol' element to listen for clicks. If the user clicked on an 'li' the source property would be the 'li' element, and 'attachedTo' would be the 'ol'.
Method Detail
{Boolean} defaultPrevented()
Has the default been prevented for this event? This should be used by whatever fires the event to determine if it should carry out of the default action.
		// fire the 'show' event
		// read if the default action has been prevented
		if ( overlayInstance.fire('show').defaultPrevented() == false ) {
		    // go ahead and show
		}
Returns:
{Boolean} Returns true if {@link glow.events.Event#preventDefault preventDefault} has been called for this event.

preventDefault()
Prevent the default action of the event. Eg, if the click event on a link is cancelled, the link is not followed. Returning false from an event listener has the same effect as calling this function. For custom events, it's down to whatever fired the event to decide what to do in this case. See {@link glow.events.Event#defaultPrevented defaultPrevented}
		myLinks.on('click', function(event) {
			event.preventDefault();
		});
		       
		// same as...
		       
		myLinks.on('click', function(event) {
			return false;
		});

Documentation generated by JsDoc Toolkit 2.3.2 on Wed Mar 03 2010 14:15:22 GMT-0000 (GMT)