patch for #809 - add the addEventType() function to the OpenLayers.Events objects so that subclasses can safely add new event types without modifying their parents' constant values

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3622 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-07-06 18:30:09 +00:00
parent bee797430d
commit a14b5bdc7e
2 changed files with 43 additions and 4 deletions
+16 -4
View File
@@ -410,7 +410,7 @@ OpenLayers.Events.prototype = {
// custom application event.
if (this.eventTypes != null) {
for (var i = 0; i < this.eventTypes.length; i++) {
this.listeners[ this.eventTypes[i] ] = new Array();
this.addEventType(this.eventTypes[i]);
}
}
@@ -437,6 +437,20 @@ OpenLayers.Events.prototype = {
this.eventHandler = null;
},
/**
* APIMethod: addEventType
* Add a new event type to this events object.
* If the event type has already been added, do nothing.
*
* Parameters:
* eventName - {String}
*/
addEventType: function(eventName) {
if (!this.listeners[eventName]) {
this.listeners[eventName] = new Array();
}
},
/**
* Method: attachToElement
*
@@ -449,9 +463,7 @@ OpenLayers.Events.prototype = {
// every browser event has a corresponding application event
// (whether it's listened for or not).
if (this.listeners[eventType] == null) {
this.listeners[eventType] = new Array();
}
this.addEventType(eventType);
// use Prototype to register the event cross-browser
OpenLayers.Event.observe(element, eventType, this.eventHandler);