OpenLayers OpenLayers

Changeset 5568

Show
Ignore:
Timestamp:
12/24/07 11:51:02 (1 year ago)
Author:
tschaub
Message:

correcting changes to feature hanlder from previous merge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Feature.js

    r5554 r5568  
    66/** 
    77 * @requires OpenLayers/Handler.js 
    8  *  
     8 */ 
     9 
     10/** 
    911 * Class: OpenLayers.Handler.Feature  
    1012 * Handler to respond to mouse events related to a drawn feature.  Callbacks 
     
    3234    /** 
    3335     * Property: feature 
     36     * {<OpenLayers.Feature.Vector>} The feature currently being handled. 
     37     */ 
     38    feature: null, 
     39 
     40    /** 
     41     * Property: lastFeature 
    3442     * {<OpenLayers.Feature.Vector>} The last feature that was handled. 
    3543     */ 
    36     feature: null, 
     44    lastFeature: null, 
    3745 
    3846    /** 
     
    132140    /** 
    133141     * Method: mousemove 
    134      * Handle mouse moves.  Call the "over" callback if move over a feature, 
    135      *     or the "out" callback if move outside any feature. 
     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. 
    136144     *  
    137145     * Parameters: 
     
    146154    }, 
    147155     
    148     /** 
    149      * Handle clicks.  Call the "click" callback if on a feature. 
    150      *  
    151      * @param {Event} evt 
    152      */ 
    153     click: function(evt) { 
    154         var selected = this.select('click', evt); 
    155         return !selected;  // stop event propagation if selected         
    156     }, 
    157  
    158156    /** 
    159157     * Method: dblclick 
     
    199197        var type = evt.type; 
    200198        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]); 
    208213                } 
    209                 this.triggerCallback(type, 'in', [feature]); 
    210                 lastFeature = feature; 
    211214                stopEvtPropag = true; 
    212215            } else { 
    213                 if(lastFeature && (lastFeature != feature)) { 
    214                     // out of last feature 
    215                     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])
    217220                } 
    218221            } 
     222            this.lastFeature = this.feature; 
    219223        } 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            } 
    227227        } 
    228228        return stopEvtPropag; 
     
    286286            } 
    287287            this.feature = null; 
     288            this.lastFeature = null; 
    288289            this.down = null; 
    289290            this.up = null;