keep the cursor style to 'move' if the cursor is above a feature. r=elemoine (closes #1673)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7713 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2008-08-08 13:34:59 +00:00
parent 3791712a10
commit f086ba17b4
2 changed files with 48 additions and 0 deletions

View File

@@ -232,6 +232,10 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
this.feature = null;
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
} else {
// the drag handler itself resetted the cursor, so
// set it back to "move" here
this.map.div.style.cursor = "move";
}
},

View File

@@ -165,6 +165,50 @@
}
function test_Control_DragFeature_up(t) {
t.plan(7);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector();
map.addLayer(layer);
var control = new OpenLayers.Control.DragFeature(layer);
map.addControl(control);
control.activate();
// simulate a mouseover on a feature
layer.getFeatureFromEvent = function(evt) {
return "foo";
}
map.events.triggerEvent("mousemove", {type: "mousemove"});
t.eq(control.over, true,
"mouseover on a feature sets the over property to true");
t.eq(control.map.div.style.cursor, "move",
"mouseover on a feature sets the cursor to move");
t.eq(control.handlers.drag.active, true,
"mouseover on a feature activates drag handler");
// simulate a mouse-up on the map, with the mouse still
// over the dragged feature
control.handlers.drag.started = true;
map.events.triggerEvent("mouseup", {type: "mouseup"});
t.eq(control.map.div.style.cursor, "move",
"mouseup while still over dragged feature does not reset cursor to default");
t.eq(control.handlers.drag.active, true,
"mouseup while still over dragged feature does not deactivate drag handler");
// simulate a mouse-up on the map, with the mouse out of
// the dragged feature
control.handlers.drag.started = true;
control.over = false;
map.events.triggerEvent("mouseup", {type: "mouseup"});
t.eq(control.map.div.style.cursor, "default",
"mouseup resets cursor to default");
t.eq(control.handlers.drag.active, false,
"mouseup deactivates drag handler");
control.deactivate();
}
function test_Control_DragFeature_done(t) {
t.plan(2);
var map = new OpenLayers.Map("map");