Hi,
I'm trying to create a control that only triggers an action whit Ctrl
+ click. But the control gets triggered with and without pressing the
Ctrl key.
Here is a minimum example, adapted from the Openlayers Click Event
example. Any ideas?

Thanks.

         var MyControl = OpenLayers.Class(OpenLayers.Control, {
                initialize: function(options) {

OpenLayers.Control.prototype.initialize.apply(this, arguments);

                    this.handler = new OpenLayers.Handler.Click(
                        this, {
                            'click': this.trigger
                        },
              {
                    'single': true,
                    'double': false,
                    'pixelTolerance': 10,
                    'stopSingle': false,
                    'stopDouble': false,
                    'keyMask': OpenLayers.Handler.MOD_CTRL
                }

                    );
                },

                trigger: function(e) {
                    var lonlat = map.getLonLatFromViewPortPx(e.xy);
                    alert("You clicked near " + lonlat.lat + " N, " +
lonlat.lon + " E");
                }

            });
            var map;
            function init(){
                map = new OpenLayers.Map('map');

                var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0?";,
{layers: 'basic'} );

                map.addLayers([ol_wms]);
                map.zoomToMaxExtent();

                var click = MyControl();
                map.addControl(click);
                click.activate();

            }
-- 


Adrià Mercader
-----------------------------
http://amercader.net
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to