Make the drag handler tidy up after itself a bit more. This solves the click blocking after shift-drag issue (see #1003).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4400 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -143,9 +143,10 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
* {Boolean} Let the event propagate.
|
* {Boolean} Let the event propagate.
|
||||||
*/
|
*/
|
||||||
mousedown: function (evt) {
|
mousedown: function (evt) {
|
||||||
|
var propagate = true;
|
||||||
|
this.dragging = false;
|
||||||
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
|
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
|
||||||
this.started = true;
|
this.started = true;
|
||||||
this.dragging = false;
|
|
||||||
this.start = evt.xy;
|
this.start = evt.xy;
|
||||||
this.last = evt.xy;
|
this.last = evt.xy;
|
||||||
// TBD replace with CSS classes
|
// TBD replace with CSS classes
|
||||||
@@ -159,9 +160,13 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
document.onselectstart = function() {return false;}
|
document.onselectstart = function() {return false;}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
propagate = false;
|
||||||
|
} else {
|
||||||
|
this.started = false;
|
||||||
|
this.start = null;
|
||||||
|
this.last = null;
|
||||||
}
|
}
|
||||||
return true;
|
return propagate;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Drag_callbacks(t) {
|
function test_Handler_Drag_callbacks(t) {
|
||||||
t.plan(27);
|
t.plan(33);
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map', {controls: []});
|
var map = new OpenLayers.Map('map', {controls: []});
|
||||||
|
|
||||||
@@ -115,10 +115,41 @@
|
|||||||
var handler = new OpenLayers.Handler.Drag(control, callbacks);
|
var handler = new OpenLayers.Handler.Drag(control, callbacks);
|
||||||
handler.activate();
|
handler.activate();
|
||||||
|
|
||||||
// test mousedown
|
|
||||||
var oldIsLeftClick = OpenLayers.Event.isLeftClick;
|
var oldIsLeftClick = OpenLayers.Event.isLeftClick;
|
||||||
var oldStop = OpenLayers.Event.stop;
|
var oldStop = OpenLayers.Event.stop;
|
||||||
var oldCheckModifiers = handler.checkModifiers;
|
var oldCheckModifiers = handler.checkModifiers;
|
||||||
|
|
||||||
|
// test mousedown with right click
|
||||||
|
OpenLayers.Event.isLeftClick = function() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handler.checkModifiers = function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
handler.started = true;
|
||||||
|
handler.start = {x: "foo", y: "bar"};
|
||||||
|
handler.last = {x: "foo", y: "bar"};
|
||||||
|
map.events.triggerEvent("mousedown", testEvents.down);
|
||||||
|
t.ok(!handler.started, "right-click sets started to false");
|
||||||
|
t.eq(handler.start, null, "right-click sets start to null");
|
||||||
|
t.eq(handler.last, null, "right-click sets last to null");
|
||||||
|
|
||||||
|
// test mousedown with improper modifier
|
||||||
|
OpenLayers.Event.isLeftClick = function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
handler.checkModifiers = function() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handler.started = true;
|
||||||
|
handler.start = {x: "foo", y: "bar"};
|
||||||
|
handler.last = {x: "foo", y: "bar"};
|
||||||
|
map.events.triggerEvent("mousedown", testEvents.down);
|
||||||
|
t.ok(!handler.started, "bad modifier sets started to false");
|
||||||
|
t.eq(handler.start, null, "bad modifier sets start to null");
|
||||||
|
t.eq(handler.last, null, "bad modifier sets last to null");
|
||||||
|
|
||||||
|
// test mousedown
|
||||||
handler.checkModifiers = function(evt) {
|
handler.checkModifiers = function(evt) {
|
||||||
t.ok(evt.xy.x == testEvents.down.xy.x &&
|
t.ok(evt.xy.x == testEvents.down.xy.x &&
|
||||||
evt.xy.y == testEvents.down.xy.y,
|
evt.xy.y == testEvents.down.xy.y,
|
||||||
@@ -151,8 +182,9 @@
|
|||||||
t.ok(handler.last.x == testEvents.down.xy.x &&
|
t.ok(handler.last.x == testEvents.down.xy.x &&
|
||||||
handler.last.y == testEvents.down.xy.y,
|
handler.last.y == testEvents.down.xy.y,
|
||||||
"mouse down sets handler.last correctly");
|
"mouse down sets handler.last correctly");
|
||||||
OpenLayers.Event.isLeftClick = oldIsLeftClick;
|
|
||||||
OpenLayers.Event.stop = oldStop;
|
OpenLayers.Event.stop = oldStop;
|
||||||
|
OpenLayers.Event.isLeftClick = oldIsLeftClick;
|
||||||
handler.checkModifiers = oldCheckModifiers;
|
handler.checkModifiers = oldCheckModifiers;
|
||||||
|
|
||||||
// test mousemove
|
// test mousemove
|
||||||
|
|||||||
Reference in New Issue
Block a user