OpenLayers OpenLayers

Changeset 3033

Show
Ignore:
Timestamp:
04/09/07 09:22:32 (2 years ago)
Author:
crschmidt
Message:

Fix for #554, click event and PanZoom control conflict, which was caused by
#484 in 2.3. This fixes the 2.2 -> current regression. Should be pulled
up to the 2.4 branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/PanZoom.js

    r2965 r3033  
    105105        OpenLayers.Event.observe(btn, "dblclick",  
    106106                                 this.doubleClick.bindAsEventListener(btn)); 
     107        OpenLayers.Event.observe(btn, "click",  
     108                                 this.doubleClick.bindAsEventListener(btn)); 
    107109        btn.action = id; 
    108110        btn.map = this.map; 
  • trunk/openlayers/tests/Control/test_PanZoom.html

    r2965 r3033  
    3737            t.plan(0) 
    3838        } else { 
    39             t.plan( 7 ); 
     39            t.plan(35); 
    4040            t.open_window( "Control/test_PanZoom.html", function( wnd ) { 
    4141                t.delay_call( 3, function() { 
    42                     simulateClick(wnd, wnd.control.buttons[0]);  
     42                    var flag; 
     43                    function setFlag(evt) { 
     44                        flag[evt.type] = true; 
     45                    } 
     46                    function resetFlags() { 
     47                        flag = { 
     48                            mousedown: false, 
     49                            mouseup: false, 
     50                            click: false, 
     51                            dblclick: false 
     52                        }; 
     53                    } 
     54                    resetFlags(); 
     55                     
     56                    wnd.mapper.events.register("mousedown", mapper, setFlag); 
     57                    wnd.mapper.events.register("mouseup", mapper, setFlag); 
     58                    wnd.mapper.events.register("click", mapper, setFlag); 
     59                    wnd.mapper.events.register("dblclick", mapper, setFlag); 
     60                     
     61                    simulateClick(wnd, wnd.control.buttons[0]); 
    4362                    t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" ); 
     63                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     64                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     65                    t.ok(!flag.click, "click does not get to the map"); 
     66                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     67                    resetFlags(); 
    4468 
    4569                    simulateClick(wnd, wnd.control.buttons[1]); 
    4670                    t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" ); 
     71                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     72                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     73                    t.ok(!flag.click, "click does not get to the map"); 
     74                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     75                    resetFlags(); 
    4776 
    4877                    simulateClick(wnd, wnd.control.buttons[2]); 
    4978                    t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" ); 
     79                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     80                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     81                    t.ok(!flag.click, "click does not get to the map"); 
     82                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     83                    resetFlags(); 
    5084 
    5185                    simulateClick(wnd, wnd.control.buttons[3]); 
    5286                    t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" ); 
     87                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     88                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     89                    t.ok(!flag.click, "click does not get to the map"); 
     90                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     91                    resetFlags(); 
    5392 
    5493                    simulateClick(wnd, wnd.control.buttons[4]); 
    5594                    t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" ); 
     95                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     96                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     97                    t.ok(!flag.click, "click does not get to the map"); 
     98                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     99                    resetFlags(); 
    56100 
    57101                    simulateClick(wnd, wnd.control.buttons[6]); 
    58102                    t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" ); 
     103                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     104                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     105                    t.ok(!flag.click, "click does not get to the map"); 
     106                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     107                    resetFlags(); 
    59108 
    60109                    simulateClick(wnd, wnd.control.buttons[5]); 
    61110                    t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" ); 
     111                    t.ok(!flag.mousedown, "mousedown does not get to the map"); 
     112                    t.ok(!flag.mouseup, "mouseup does not get to the map"); 
     113                    t.ok(!flag.click, "click does not get to the map"); 
     114                    t.ok(!flag.dblclick, "dblclick does not get to the map"); 
     115                    resetFlags(); 
     116                     
    62117                }); 
    63118            }); 
     
    68123      var evt = wnd.document.createEvent("MouseEvents"); 
    69124      evt.initMouseEvent("mousedown", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
    70       var canceled = !elem.dispatchEvent(evt); 
     125      elem.dispatchEvent(evt); 
     126 
     127      evt = wnd.document.createEvent("MouseEvents"); 
     128      evt.initMouseEvent("mouseup", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
     129      elem.dispatchEvent(evt); 
     130 
     131      evt = wnd.document.createEvent("MouseEvents"); 
     132      evt.initMouseEvent("click", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
     133      elem.dispatchEvent(evt); 
     134 
     135      evt = wnd.document.createEvent("MouseEvents"); 
     136      evt.initMouseEvent("dblclick", true, true, wnd, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
     137      elem.dispatchEvent(evt); 
    71138    } 
    72139