select features on "click" as opposed to on "mousedown" (closes #891)

thanks to all for the review and to crschmidt for updating the patch


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4241 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2007-09-12 14:25:34 +00:00
parent 446759fd65
commit 6f16455b1c
3 changed files with 161 additions and 6 deletions

View File

@@ -76,7 +76,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.callbacks = OpenLayers.Util.extend({
down: this.downFeature,
click: this.clickFeature,
over: this.overFeature,
out: this.outFeature
}, this.callbacks);
@@ -85,13 +85,13 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
},
/**
* Method: downFeature
* Called when the feature handler detects a mouse-down on a feature
* Method: clickFeature
* Called when the feature handler detects a click on a feature
*
* Parameters:
* feature - {<OpenLayers.Vector.Feature>}
*/
downFeature: function(feature) {
clickFeature: function(feature) {
if(this.hover) {
return;
}

View File

@@ -8,8 +8,8 @@
*
* Class: OpenLayers.Handler.Feature
* Handler to respond to mouse events related to a drawn feature.
* Callbacks will be called for over, move, out, up, and down (corresponding
* to the equivalent mouse events).
* Callbacks will be called for over, move, out, up, down, and click
* (corresponding to the equivalent mouse events).
*/
OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {
@@ -41,6 +41,18 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {
this.layer = layer;
},
/**
* Method: click
* Handle click. Call the "click" callback if down on a feature.
*
* Parameters:
* evt - {Event}
*/
click: function(evt) {
var selected = this.select('click', evt);
return !selected; // stop event propagation if selected
},
/**
* Method: mousedown
* Handle mouse down. Call the "down" callback if down on a feature.