OpenLayers OpenLayers

Changeset 6066

Show
Ignore:
Timestamp:
02/07/08 22:24:42 (1 year ago)
Author:
tschaub
Message:

By default, the click handler now has a zero pixelTolerance. This means we don't call click if the click includes a drag. Set pixelTolerance to null if you want click called with a drag. r=crschmidt (closes #1335)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/click-handler.html

    r5438 r6066  
    3939                    'single': true, 
    4040                    'double': false, 
    41                     'pixelTolerance': null
     41                    'pixelTolerance': 0
    4242                    'stopSingle': false, 
    4343                    'stopDouble': false 
     
    103103                        } 
    104104                    }), 
    105                     "nodrag": new OpenLayers.Control.Click({ 
     105                    "drag": new OpenLayers.Control.Click({ 
    106106                        handlerOptions: { 
    107107                            "single": true, 
    108                             "pixelTolerance": 1 
     108                            "pixelTolerance": null 
    109109                        } 
    110110                    }), 
     
    205205                    </tr> 
    206206                    <tr> 
    207                         <td>single no drag</td> 
    208                         <td><button id="nodragStatus" onclick="toggle('nodrag')">off</button></td> 
    209                         <td><textarea class="output" id="nodragOutput"></textarea></td> 
     207                        <td>single with drag</td> 
     208                        <td><button id="dragStatus" onclick="toggle('drag')">off</button></td> 
     209                        <td><textarea class="output" id="dragOutput"></textarea></td> 
    210210                    </tr> 
    211211                    <tr> 
  • trunk/openlayers/lib/OpenLayers/Handler/Click.js

    r5698 r6066  
    4646     * APIProperty: pixelTolerance 
    4747     * {Number} Maximum number of pixels between mouseup and mousedown for an 
    48      *     event to be considered a click.  Default is null.  If set to an 
     48     *     event to be considered a click.  Default is 0.  If set to an 
    4949     *     integer value, clicks with a drag greater than the value will be 
    5050     *     ignored.  This property can only be set when the handler is 
    5151     *     constructed. 
    5252     */ 
    53     pixelTolerance: null
     53    pixelTolerance: 0
    5454     
    5555    /** 
     
    183183    passesTolerance: function(evt) { 
    184184        var passes = true; 
    185         if(this.pixelTolerance && this.down) { 
     185        if(this.pixelTolerance != null && this.down) { 
    186186            var dpx = Math.sqrt( 
    187187                Math.pow(this.down.x - evt.xy.x, 2) + 
  • trunk/openlayers/tests/Handler/test_Click.html

    r5685 r6066  
    4444     
    4545    function test_Handler_Click_events(t) { 
    46         t.plan(30); 
     46        t.plan(35); 
    4747         
    4848        var map = new OpenLayers.Map('map'); 
     
    7373        // list below events that should be handled (events) and those 
    7474        // that should not be handled (nonevents) by the handler 
    75         var events = ["click", "dblclick"]; 
    76         var nonevents = ["mousedown", "mousemove", "mouseup", "resize", "focus", "blur"]; 
     75        var events = ["click", "dblclick", "mousedown"]; 
     76        var nonevents = ["mousemove", "mouseup", "resize", "focus", "blur"]; 
    7777        var handler = new OpenLayers.Handler.Click(control); 
    7878        // set browser event like properties on the handler