Fixed onselect handling for the first down-move-up-out cycle. r=bartvde (closes #2735)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10637 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-08-19 14:52:45 +00:00
parent 94c29f1d4d
commit 7993fc177b
2 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -200,8 +200,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
if(!this.oldOnselectstart) { if(!this.oldOnselectstart) {
this.oldOnselectstart = (document.onselectstart) ? document.onselectstart : OpenLayers.Function.True; this.oldOnselectstart = (document.onselectstart) ? document.onselectstart : OpenLayers.Function.True;
document.onselectstart = OpenLayers.Function.False;
} }
document.onselectstart = OpenLayers.Function.False;
propagate = !this.stopDown; propagate = !this.stopDown;
} else { } else {
+12 -1
View File
@@ -289,7 +289,7 @@
} }
function test_Handler_Drag_submethods(t) { function test_Handler_Drag_submethods(t) {
t.plan(4); t.plan(8);
var map = new OpenLayers.Map('map', {controls: []}); var map = new OpenLayers.Map('map', {controls: []});
@@ -300,6 +300,11 @@
var handler = new OpenLayers.Handler.Drag(control, {}); var handler = new OpenLayers.Handler.Drag(control, {});
// set test events // set test events
var events = ["down", "move", "up", "out"]; var events = ["down", "move", "up", "out"];
var onselect = {
"move": OpenLayers.Function.False,
"up": OpenLayers.Function.False,
"out": OpenLayers.Function.True
}
var testEvents = {}; var testEvents = {};
var type, px; var type, px;
for(var i=0; i<events.length; ++i) { for(var i=0; i<events.length; ++i) {
@@ -313,10 +318,14 @@
t.ok(evt.xy.x == testEvents[type].xy.x && t.ok(evt.xy.x == testEvents[type].xy.x &&
evt.xy.y == testEvents[type].xy.y, evt.xy.y == testEvents[type].xy.y,
"handler." + type + " called with the right event"); "handler." + type + " called with the right event");
onselect[type] && t.ok(document.onselectstart === onselect[type], "document.onselectstart listener is correct after " + type);
} }
} }
handler.activate(); handler.activate();
// pretend that we have gone through a down-move-up-out cycle before
handler.oldOnselectstart = OpenLayers.Function.True;
// test mousedown // test mousedown
handler.checkModifiers = function(evt) { handler.checkModifiers = function(evt) {
return true; return true;
@@ -343,6 +352,8 @@
map.events.triggerEvent("mouseout", testEvents.out); map.events.triggerEvent("mouseout", testEvents.out);
OpenLayers.Util.mouseLeft = oldMouseLeft; OpenLayers.Util.mouseLeft = oldMouseLeft;
t.ok(document.onselectstart === OpenLayers.Function.True, "document.onselectstart listener correct after down-move-up-out cycle");
} }
function test_Handler_Drag_deactivate(t) { function test_Handler_Drag_deactivate(t) {