Adding eventListeners property to layer, control, and map. Setting this property at construction registers the given listeners based on event type key. r=elemoine (closes #1404)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6435 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-03-05 00:07:46 +00:00
parent 0c03b8e631
commit 894c457fdd
7 changed files with 117 additions and 1 deletions

View File

@@ -104,6 +104,15 @@ OpenLayers.Control = OpenLayers.Class({
*/
handler: null,
/**
* APIProperty: eventListeners
* {Object} If set as an option at construction, the eventListeners
* object will be registered with <OpenLayers.Events.on>. Object
* structure must be a listeners object as shown in the example for
* the events.on method.
*/
eventListeners: null,
/**
* Property: events
* {<OpenLayers.Events>} Events instance for triggering control specific
@@ -155,6 +164,9 @@ OpenLayers.Control = OpenLayers.Class({
OpenLayers.Util.extend(this, options);
this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES);
if(this.eventListeners instanceof Object) {
this.events.on(this.eventListeners);
}
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
},
@@ -230,7 +242,7 @@ OpenLayers.Control = OpenLayers.Class({
if (px != null) {
this.position = px.clone();
}
this.moveTo(this.position);
this.moveTo(this.position);
return this.div;
},