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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user