diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index 246ca86ded..6e1229167d 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -147,9 +147,7 @@ OpenLayers.Control.LayerSwitcher.prototype = backdropLabel.layer = layer; // set event handlers - backdropLabelOuter.onclick = this.ignoreEvent.bindAsEventListener(this); - backdropLabelOuter.ondblclick = this.ignoreEvent.bindAsEventListener(this); - backdropLabelOuter.onmousedown = this.singleClick.bindAsEventListener(this); + this._setEventHandlers(backdropLabel); // add label to div backdropLabelOuter.appendChild(backdropLabel); @@ -167,7 +165,19 @@ OpenLayers.Control.LayerSwitcher.prototype = this.setTabActivation(backdropLabel, layer.getVisibility()); }, + /* + @private + + @param {DOMElement} div + @param {Boolean} activate + */ + _setEventHandlers : function(element) { + // We only want to respond to a mousedown event. + element.onclick = this.ignoreEvent.bindAsEventListener(this); + element.ondblclick = this.ignoreEvent.bindAsEventListener(this); + element.onmousedown = this.singleClick.bindAsEventListener(this); + }, /** * @private