[OpenLayers-Users] Click handler not handling clicks after using editing toolbar

Dylan Parry me at dylanparry.com
Tue Mar 16 03:23:21 EDT 2010


Hi,

I’ve set up a click handler on my map to handle double-clicks. I did 
this by bastardising the demo for click handlers, so the code I have is 
as follows:

--- start ---
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { 

	defaultHandlerOptions: {
		'single': true,
		'double': true,
		'pixelTolerance': 0,
		'stopSingle': false,
		'stopDouble': true
	},
		
	initialize: function(options) {
		this.handlerOptions = OpenLayers.Util.extend(
			{}, this.defaultHandlerOptions
		);
		OpenLayers.Control.prototype.initialize.apply(
			this, arguments
		);
		this.handler = new OpenLayers.Handler.Click(
			this, {
				'dblclick': this.onDblclick
			}, this.handlerOptions
		);
	},
		
	onDblclick: function(evt) {
		// A jQuery function that isn’t relevant here
	}
});
	
// Double click handler
var doubleClick = new OpenLayers.Control.Click({
	handlerOptions: {
		"single": false,
		"double": true,
		"stopDouble": true
	}
});
map.addControl(doubleClick);
doubleClick.activate();
--- end ---

All this code lives in the function that initialises the map. I’ve also 
got an editing toolbar on the map, which is added to the map controls 
during initialisation.

The double click handler works just fine, but if I click on any of the 
buttons in the editing toolbar, then click back to the “move” button, it 
no longer handles the double click events and the map then zooms in when 
I double click, instead of running my custom function.

Any ideas what I can do to stop this from happening? Is there maybe an 
event that fires when you click the edit toolbar buttons that I can 
re-register my click handler in?

Cheers,

-- 
Dylan Parry



More information about the Users mailing list