Changeset 5568
- Timestamp:
- 12/24/07 11:51:02 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Feature.js
r5554 r5568 6 6 /** 7 7 * @requires OpenLayers/Handler.js 8 * 8 */ 9 10 /** 9 11 * Class: OpenLayers.Handler.Feature 10 12 * Handler to respond to mouse events related to a drawn feature. Callbacks … … 32 34 /** 33 35 * Property: feature 36 * {<OpenLayers.Feature.Vector>} The feature currently being handled. 37 */ 38 feature: null, 39 40 /** 41 * Property: lastFeature 34 42 * {<OpenLayers.Feature.Vector>} The last feature that was handled. 35 43 */ 36 feature: null,44 lastFeature: null, 37 45 38 46 /** … … 132 140 /** 133 141 * Method: mousemove 134 * Handle mouse moves. Call the "over" callback if mov e overa feature,135 * or the "out" callback if mov e outside anyfeature.142 * Handle mouse moves. Call the "over" callback if moving in to a feature, 143 * or the "out" callback if moving out of a feature. 136 144 * 137 145 * Parameters: … … 146 154 }, 147 155 148 /**149 * Handle clicks. Call the "click" callback if on a feature.150 *151 * @param {Event} evt152 */153 click: function(evt) {154 var selected = this.select('click', evt);155 return !selected; // stop event propagation if selected156 },157 158 156 /** 159 157 * Method: dblclick … … 199 197 var type = evt.type; 200 198 var stopEvtPropag = false; 201 var lastFeature = this.feature; 202 var feature = this.layer.getFeatureFromEvent(evt); 203 if(feature) { 204 if(this.geometryTypeMatches(feature)) { 205 if(lastFeature && (lastFeature != feature)) { 206 // out of last feature 207 this.triggerCallback(type, 'out', [lastFeature]); 199 var previouslyIn = !!(this.feature); // previously in a feature 200 var click = (type == "click" || type == "dblclick"); 201 this.feature = this.layer.getFeatureFromEvent(evt); 202 if(this.feature) { 203 var inNew = (this.feature != this.lastFeature); 204 if(this.geometryTypeMatches(this.feature)) { 205 // in to a feature 206 if(previouslyIn && inNew) { 207 // out of last feature and in to another 208 this.triggerCallback(type, 'out', [this.lastFeature]); 209 this.triggerCallback(type, 'in', [this.feature]); 210 } else if(!previouslyIn || click) { 211 // in feature for the first time 212 this.triggerCallback(type, 'in', [this.feature]); 208 213 } 209 this.triggerCallback(type, 'in', [feature]);210 lastFeature = feature;211 214 stopEvtPropag = true; 212 215 } else { 213 if(lastFeature && (lastFeature != feature)) {214 // out of last feature215 this.triggerCallback(type, 'out', [lastFeature]);216 lastFeature = feature;216 // not in to a feature 217 if(previouslyIn && inNew || (click && this.lastFeature)) { 218 // out of last feature for the first time 219 this.triggerCallback(type, 'out', [this.lastFeature]); 217 220 } 218 221 } 222 this.lastFeature = this.feature; 219 223 } else { 220 if(lastFeature) { 221 this.triggerCallback(type, 'out', [lastFeature]); 222 lastFeature = null; 223 } 224 } 225 if(lastFeature) { 226 this.feature = lastFeature; 224 if(previouslyIn || (click && this.lastFeature)) { 225 this.triggerCallback(type, 'out', [this.lastFeature]); 226 } 227 227 } 228 228 return stopEvtPropag; … … 286 286 } 287 287 this.feature = null; 288 this.lastFeature = null; 288 289 this.down = null; 289 290 this.up = null;
