Oh and by the way, here's what I did for the Control (attached). Is it
ok (too much, i.e. about the use of hasOwnProperty functions) ?
Thanks,
Alexandre
Alexandre Dube wrote:
Eric Lemoine wrote:
so, to get to the delete control you've been working on, I see more
value, in terms of flexibility, in adding "control composition" to the
control base class.
I also agree. Originally, the control had a Feature handler instead of
a SelectFeature control. Looking at it now, it's too simple to be
justified as a new control.
About the 'controls' property and the act./dea. automatism : that's a good
idea, but wouldn't it be good to have a 'handlers' property also and
activate/deactivate all handlers as well ? Currently, control has a 'handler'
property only. Would it make sense to have 'handlers' added a do the same kind
of automatism as the new 'controls' property ?
Agreed.
Great.
--
Alexandre Dubé
Mapgears
www.mapgears.com
Index: Control.js
===================================================================
--- Control.js (revision 9573)
+++ Control.js (working copy)
@@ -117,6 +117,20 @@
*/
handler: null,
+ /**
+ * Property: handlers
+ * {Array of(<OpenLayers.Handler>)} null
+ */
+ handlers: null,
+
+ /**
+ * Property: controls
+ * Controls can contain other controls. When this control is activated, all
+ * its child controls, i.e. this.controls should be activated as well.
+ * {Array of(<OpenLayers.Controls>)} null
+ */
+ controls: null,
+
/**
* APIProperty: eventListeners
* {Object} If set as an option at construction, the eventListeners
@@ -235,6 +249,22 @@
if (this.handler) {
this.handler.setMap(map);
}
+ if(this.handlers) {
+ for(var key in this.handlers) {
+ if(this.handlers.hasOwnProperty(key) &&
+ typeof this.handlers[key].setMap == "function") {
+ this.handlers[key].setMap(map);
+ }
+ }
+ }
+ if(this.controls) {
+ for(var key in this.controls) {
+ if(this.controls.hasOwnProperty(key) &&
+ typeof this.controls[key].setMap == "function") {
+ this.controls[key].setMap(map);
+ }
+ }
+ }
},
/**
@@ -303,6 +333,22 @@
if (this.handler) {
this.handler.activate();
}
+ if(this.handlers) {
+ for(var key in this.handlers) {
+ if(this.handlers.hasOwnProperty(key) &&
+ typeof this.handlers[key].activate == "function") {
+ this.handlers[key].activate();
+ }
+ }
+ }
+ if(this.controls) {
+ for(var key in this.controls) {
+ if(this.controls.hasOwnProperty(key) &&
+ typeof this.controls[key].activate == "function") {
+ this.controls[key].activate();
+ }
+ }
+ }
this.active = true;
if(this.map) {
OpenLayers.Element.addClass(
@@ -328,6 +374,22 @@
if (this.handler) {
this.handler.deactivate();
}
+ if(this.handlers) {
+ for(var key in this.handlers) {
+ if(this.handlers.hasOwnProperty(key) &&
+ typeof this.handlers[key].deactivate == "function") {
+ this.handlers[key].deactivate();
+ }
+ }
+ }
+ if(this.controls) {
+ for(var key in this.controls) {
+ if(this.controls.hasOwnProperty(key) &&
+ typeof this.controls[key].deactivate == "function") {
+ this.controls[key].deactivate();
+ }
+ }
+ }
this.active = false;
if(this.map) {
OpenLayers.Element.removeClass(
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev