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
This commit is contained in:
Tim Schaub
2008-02-08 03:24:42 +00:00
parent fba4528c9a
commit 99f3fa0d26
3 changed files with 12 additions and 12 deletions

View File

@@ -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 @@
<td><textarea class="output" id="bothOutput"></textarea></td>
</tr>
<tr>
<td>single no drag</td>
<td><button id="nodragStatus" onclick="toggle('nodrag')">off</button></td>
<td><textarea class="output" id="nodragOutput"></textarea></td>
<td>single with drag</td>
<td><button id="dragStatus" onclick="toggle('drag')">off</button></td>
<td><textarea class="output" id="dragOutput"></textarea></td>
</tr>
<tr>
<td>single with stop</td>

View File

@@ -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)

View File

@@ -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<events.length; ++i) {