[OpenLayers-Users] How to disable <ctrl> drag

Jan Hartmann j.l.h.hartmann at uva.nl
Tue Feb 21 12:19:27 EST 2012


This works:

var control = new OpenLayers.Control();
     OpenLayers.Util.extend(control, {
     draw: function () {
         // this Handler.Box will intercept the ctrl-mousedown
         // before Control.MouseDefault gets to see it
         this.drag = new OpenLayers.Handler.Drag( control,
             {"done": this.notice},
             {keyMask: OpenLayers.Handler.MOD_CTRL});
         this.drag.activate();
     },

     notice: function () {
         return(true)
     }
map.addControl(control);

Thanks Ryan,

Jan


On 02/21/2012 05:16 PM, Ryan Williams wrote:
> Jan,
>  There's a short example on the OpenLayers docs that sounds similar. 
> http://dev.openlayers.org/docs/files/OpenLayers/Control-js.html
> It doesn't use the map.events.register though.
> It shows how to use OpenLayers.Util.extend to create a control that 
> will work when the user is holding down the Shift key. It intercepts 
> the shift-mouse click, lets the user drag out a box, and then does 
> something with the bounds of that box.
> It uses the OpenLayers.Handler.MOD_SHIFT keymask. There is also a 
> MOD_CTRL keymask you could use as well.
> http://dev.openlayers.org/docs/files/OpenLayers/Handler-js.html#OpenLayers.Handler.OpenLayers.Handler.MOD_CTRL
>
> I use the MOD_SHIFT keymask to let users drag out a box over a map and 
> it works fine.
> - Ryan
>
> On 2/21/2012 9:54 AM, Jan Hartmann wrote:
>> Hi all,
>>
>> I have written a small application to input points with <ctrl><click> 
>> from an OpenLayers map using 
>> "map.events.register("click",map,function(e) { ...}". Works fine, but 
>> when the user moves the mouse when clicking, the default behavior 
>> takes over: the map is panned and no input takes place. How can I 
>> disable panning when the <ctrl> key is  down?
>>
>> Jan
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
> -- 
> Ryan Williams
> GIS Analyst / Programmer
> PAQ Interactive Inc.
> rwilliams at paqinteractive.com
> 217-762-7955
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120221/de042fce/attachment.html


More information about the Users mailing list