OpenLayers OpenLayers

Changeset 1481

Show
Ignore:
Timestamp:
09/18/06 14:48:29 (2 years ago)
Author:
crschmidt
Message:

Pullup fixes to mouse controls since 2.1-rc1, along with a fix for
zooming.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.1/doc/Layer.txt

    r1424 r1481  
    1313  setName({String|name}) -- none -- Set the name of the layer to something different. 
    1414  moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location. 
    15   reproject() -- none -- Subclassed by vector layers to redraw vectors when base layer changes. 
    1615  setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map. 
    1716  getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer. 
  • branches/openlayers/2.1/lib/OpenLayers/Control/MouseDefaults.js

    r1447 r1481  
    142142    */ 
    143143    defaultMouseOut: function (evt) { 
    144         if (this.mouseDragStart != null 
    145             && OpenLayers.Util.mouseLeft(evt, this.map.div)) { 
    146                 this.defaultMouseUp(evt); 
     144        if (this.mouseDragStart != null &&  
     145            OpenLayers.Util.mouseLeft(evt, this.map.div)) { 
     146            if (this.zoomBox) { 
     147                this.removeZoomBox(); 
     148            } 
     149            this.mouseDragStart = null; 
    147150        } 
    148151    }, 
     
    189192                 ), this.map.getZoom() + 1); 
    190193            }     
    191             this.map.viewPortDiv.removeChild(this.zoomBox); 
    192             this.zoomBox = null; 
    193        }      
     194            this.removeZoomBox(); 
     195       } 
     196    }, 
     197 
     198    /** 
     199     * Remove the zoombox from the screen and nullify our reference to it. 
     200     */ 
     201    removeZoomBox: function() { 
     202        this.map.viewPortDiv.removeChild(this.zoomBox); 
     203        this.zoomBox = null; 
    194204    }, 
    195205 
  • branches/openlayers/2.1/lib/OpenLayers/Control/MouseToolbar.js

    r1424 r1481  
    2121 
    2222    direction: "vertical", 
     23     
     24    /** @type String */ 
     25    buttonClicked: null, 
    2326     
    2427    initialize: function(position, direction) { 
     
    6366        btn.activeImgLocation = activeImgLocation; 
    6467         
    65         btn.events = new OpenLayers.Events(this, btn); 
    66         btn.events.register("mousedown", this, this.buttonClick);  
    67         btn.events.register("mouseup", this, Event.stop); 
    68         btn.events.register("click", this, Event.stop); 
     68        btn.events = new OpenLayers.Events(this, btn, null, true); 
     69        btn.events.register("mousedown", this, this.buttonDown);  
     70        btn.events.register("mouseup", this, this.buttonUp);  
     71        btn.events.register("dblclick", this, Event.stop); 
    6972        btn.action = id; 
    7073        btn.title = title; 
     
    7780    }, 
    7881 
    79     buttonClick: function(evt) { 
     82    /** 
     83     * @param {Event} evt 
     84     */ 
     85    buttonDown: function(evt) { 
    8086        if (!Event.isLeftClick(evt)) return; 
    81         this.switchModeTo(evt.element.action)
     87        this.buttonClicked = evt.element.action
    8288        Event.stop(evt); 
     89    }, 
     90 
     91    /** 
     92     * @param {Event} evt 
     93     */ 
     94    buttonUp: function(evt) { 
     95        if (!Event.isLeftClick(evt)) return; 
     96        if (this.buttonClicked != null) { 
     97            if (this.buttonClicked == evt.element.action) { 
     98                this.switchModeTo(evt.element.action); 
     99            } 
     100            Event.stop(evt); 
     101            this.buttonClicked = null; 
     102        } 
    83103    }, 
    84104     
     
    90110        this.performedDrag = false; 
    91111        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
    92         this.map.setCenter(newCenter, this.map.zoom + 2); 
     112        this.map.setCenter(newCenter, this.map.zoom + 1); 
    93113        Event.stop(evt); 
    94114        return false; 
     
    180200    switchModeTo: function(mode) { 
    181201        if (mode != this.mode) { 
     202             
     203 
    182204            if (this.mode && this.buttons[this.mode]) { 
    183205                OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); 
     
    196218                OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); 
    197219            } 
     220            switch (this.mode) { 
     221                case "zoombox": 
     222                    this.map.div.style.cursor = "crosshair"; 
     223                    break; 
     224                default: 
     225                    this.map.div.style.cursor = "default"; 
     226                    break; 
     227            } 
     228 
    198229        }  
    199230    },  
     
    255286    }, 
    256287 
     288    /** 
     289    * @param {Event} evt 
     290    */ 
    257291    defaultMouseOut: function (evt) { 
    258292        if (this.mouseDragStart != null 
    259293            && OpenLayers.Util.mouseLeft(evt, this.map.div)) { 
    260                 this.defaultMouseUp(evt); 
    261         } 
    262     }, 
     294            if (this.zoomBox) { 
     295                this.removeZoomBox(); 
     296                if (this.startViaKeyboard) this.leaveMode(); 
     297            } 
     298            this.mouseDragStart = null; 
     299            this.map.div.style.cursor = "default"; 
     300        } 
     301    }, 
     302 
    263303    defaultClick: function (evt) { 
    264304        if (this.performedDrag)  { 
  • branches/openlayers/2.1/lib/OpenLayers/Control/PanZoomBar.js

    r1424 r1481  
    8787        this.slider = slider; 
    8888         
    89         this.sliderEvents = new OpenLayers.Events(this, slider); 
     89        this.sliderEvents = new OpenLayers.Events(this, slider, null, true); 
    9090        this.sliderEvents.register("mousedown", this, this.zoomBarDown); 
    9191        this.sliderEvents.register("mousemove", this, this.zoomBarDrag); 
     
    117117        this.zoombarDiv = div; 
    118118         
    119         this.divEvents = new OpenLayers.Events(this, div); 
     119        this.divEvents = new OpenLayers.Events(this, div, null, true); 
    120120        this.divEvents.register("mousedown", this, this.divClick); 
    121121        this.divEvents.register("mousemove", this, this.passEventToSlider); 
  • branches/openlayers/2.1/lib/OpenLayers/Events.js

    r1424 r1481  
    3838     * @param {DOMElement} element A dom element to respond to browser events 
    3939     * @param {Array} eventTypes Array of custom application events 
    40      */ 
    41     initialize: function (object, element, eventTypes) { 
     40     * @param {Boolean} fallThrough Allow events to fall through after these  
     41     *                              have been handled? 
     42     */ 
     43    initialize: function (object, element, eventTypes, fallThrough) { 
    4244        this.object     = object; 
    4345        this.element    = element; 
    4446        this.eventTypes = eventTypes; 
     47        this.fallThrough = fallThrough; 
    4548        this.listeners  = new Object(); 
    4649 
     
    177180            } 
    178181            // don't fall through to other DOM elements 
    179             Event.stop(evt); 
     182            if (!this.fallThrough) {             
     183                Event.stop(evt); 
     184            } 
    180185        } 
    181186    }, 
  • branches/openlayers/2.1/lib/OpenLayers/Layer.js

    r1448 r1481  
    323323            }     
    324324        } 
    325         this.resolutions = this.resolutions.sort().reverse(); 
    326325    }, 
    327326 
  • branches/openlayers/2.1/lib/OpenLayers/Popup.js

    r1438 r1481  
    251251     */ 
    252252     registerEvents:function() { 
    253         Event.observe(this.div, "mousedown",  
    254                       this.onmousedown.bindAsEventListener(this)); 
    255         Event.observe(this.div, "mousemove",  
    256                       this.onmousemove.bindAsEventListener(this)); 
    257         Event.observe(this.div, "mouseup",  
    258                       this.onmouseup.bindAsEventListener(this)); 
    259         Event.observe(this.div, "click",  
    260                       OpenLayers.Util.safeStopPropagation); 
    261         Event.observe(this.div, "mouseout",  
    262                       this.onmouseout.bindAsEventListener(this)); 
    263         Event.observe(this.div, "dblclick",  
    264                       OpenLayers.Util.safeStopPropagation); 
     253        this.events = new OpenLayers.Events(this, this.div, null, true); 
     254 
     255        this.events.register("mousedown", this, this.onmousedown); 
     256        this.events.register("mousemove", this, this.onmousemove); 
     257        this.events.register("mouseup", this, this.onmouseup); 
     258        this.events.register("click", this,  
     259                             OpenLayers.Util.safeStopPropagation); 
     260        this.events.register("mouseout", this, this.onmouseout); 
     261        this.events.register("dblclick", this,  
     262                             OpenLayers.Util.safeStopPropagation); 
    265263     }, 
    266264