From 99f3fa0d26feed7d0b1ab59f4845d2dc7483394d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 8 Feb 2008 03:24:42 +0000 Subject: [PATCH] By default, the click handler now has a zero pixelTolerance. This means we don't call click if the click includes a drag. Set pixelTolerance to null if you want click called with a drag. r=crschmidt (closes #1335) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6066 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/click-handler.html | 12 ++++++------ lib/OpenLayers/Handler/Click.js | 6 +++--- tests/Handler/test_Click.html | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/click-handler.html b/examples/click-handler.html index 17c541d715..1e8323a54b 100644 --- a/examples/click-handler.html +++ b/examples/click-handler.html @@ -38,7 +38,7 @@ defaultHandlerOptions: { 'single': true, 'double': false, - 'pixelTolerance': null, + 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, @@ -102,10 +102,10 @@ "double": true } }), - "nodrag": new OpenLayers.Control.Click({ + "drag": new OpenLayers.Control.Click({ handlerOptions: { "single": true, - "pixelTolerance": 1 + "pixelTolerance": null } }), "stopsingle": new OpenLayers.Control.Click({ @@ -204,9 +204,9 @@ - single no drag - - + single with drag + + single with stop diff --git a/lib/OpenLayers/Handler/Click.js b/lib/OpenLayers/Handler/Click.js index 0ff5246c12..4195fd0b51 100644 --- a/lib/OpenLayers/Handler/Click.js +++ b/lib/OpenLayers/Handler/Click.js @@ -45,12 +45,12 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, { /** * APIProperty: pixelTolerance * {Number} Maximum number of pixels between mouseup and mousedown for an - * event to be considered a click. Default is null. If set to an + * event to be considered a click. Default is 0. If set to an * integer value, clicks with a drag greater than the value will be * ignored. This property can only be set when the handler is * constructed. */ - pixelTolerance: null, + pixelTolerance: 0, /** * APIProperty: stopSingle @@ -182,7 +182,7 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, { */ passesTolerance: function(evt) { var passes = true; - if(this.pixelTolerance && this.down) { + if(this.pixelTolerance != null && this.down) { var dpx = Math.sqrt( Math.pow(this.down.x - evt.xy.x, 2) + Math.pow(this.down.y - evt.xy.y, 2) diff --git a/tests/Handler/test_Click.html b/tests/Handler/test_Click.html index 39c478fdae..c0fe4a30b5 100644 --- a/tests/Handler/test_Click.html +++ b/tests/Handler/test_Click.html @@ -43,7 +43,7 @@ } function test_Handler_Click_events(t) { - t.plan(30); + t.plan(35); var map = new OpenLayers.Map('map'); var control = { @@ -72,8 +72,8 @@ // list below events that should be handled (events) and those // that should not be handled (nonevents) by the handler - var events = ["click", "dblclick"]; - var nonevents = ["mousedown", "mousemove", "mouseup", "resize", "focus", "blur"]; + var events = ["click", "dblclick", "mousedown"]; + var nonevents = ["mousemove", "mouseup", "resize", "focus", "blur"]; var handler = new OpenLayers.Handler.Click(control); // set browser event like properties on the handler for(var i=0; i