[OpenLayers-Users] mousedown

Greg Ederer greg at ergonosis.com
Mon May 4 13:51:18 EDT 2009


For reference, here's my code so far:

       OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
         defaultHandlerOptions: {
           'single': true,
           'double': false,
           'mousedown' : false,
           'pixelTolerance': 0,
           'stopSingle': false,
           'stopDouble': false
         },

         initialize: function(options)
         {
           this.handlerOptions = OpenLayers.Util.extend(
           {}, this.defaultHandlerOptions
             );
           OpenLayers.Control.prototype.initialize.apply(
             this, arguments
             );
           this.handler = new OpenLayers.Handler.Click(
             this, {
               'click': this.onClick,
               'dblclick': this.onDblclick,
               'mousedown' : this.onMouseDown
             }, this.handlerOptions
             );
         },

         onMouseDown : function(evt)
         {
           alert('hi');
         },

         ...

       var controls = {
         "single": new OpenLayers.Control.Click({
           hanlerOptions: {
             "single": true
           }
         }),
         "mousedown": new OpenLayers.Control.Click({
           hanlerOptions: {
             "single": true
           }
         }),
         "double": new OpenLayers.Control.Click({
           handlerOptions: {
             "single": false,
             "double": true
           }
         }),
         "both": new OpenLayers.Control.Click({
           handlerOptions: {
             "single": true,
             "double": true
           }
         }),
         "drag": new OpenLayers.Control.Click({
           handlerOptions: {
             "single": true,
             "pixelTolerance": null
           }
         }),
         "stopsingle": new OpenLayers.Control.Click({
           handlerOptions: {
             "single": true,
             "stopSingle": true
           }
         }),
         "stopdouble": new OpenLayers.Control.Click({
           handlerOptions: {
             "single": false,
             "double": true,
             "stopDouble": true
           }
         })
       };

       var control;
       for(var key in controls) {
         control = controls[key];
         // only to route output here
         control.key = key;
         this.map.addControl(control);
       //console.log('added control: ' + key);
       }

But, onMouseDown never gets called.

Greg

On May 4, 2009, at 10:16 AM, Greg Ederer wrote:

> Hi,
>
> I need to capture mousedown events on a Map.  I'm using a custom
> OpenLayers.Control.Click for click and dblclick.  But, Click does not
> appear to handle mousedown events.  Any suggestions?
>
> Thanks!
>
> Greg
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list