ThinkGeo.com    |     Documentation    |     Premium Support

Draw on Right Click issue

On the "Draw and Edit Shapes" sample application, I am able to draw using the right mouse click for the Polyline, Line and Point. The rectangle, circle and ellipse shapes right click are disable. For consistency, is there a way to disable the abilities to draw on right click for all shapes. 


Step to re-produce


1. Select a shape with left mouse


2. right click on map and draw 


Thanks in advance



ttd,


Please try the code below:




 [script removed]
        OnMapCreating = function() {
            OpenLayers.Handler.Point.prototype.mousedown = function(evt) {
                if (evt.button != 2) {
                    // check keyboard modifiers
                    if (!this.checkModifiers(evt)) {
                        return true;
                    }
                    // ignore double-clicks
                    if (this.lastDown && this.lastDown.equals(evt.xy)) {
                        return true;
                    }
                    this.drawing = true;
                    if (this.lastDown == null) {
                        if (this.persist) {
                            this.destroyFeature();
                        }
                        this.createFeature(evt.xy);
                    } else {
                        this.modifyFeature(evt.xy);
                    }
                    this.lastDown = evt.xy;
                }
                return false;
            };
            OpenLayers.Handler.Path.prototype.mousedown = function(evt) {
                if (evt.button != 2) {
                    // ignore double-clicks
                    if (this.lastDown && this.lastDown.equals(evt.xy)) {
                        return false;
                    }
                    if (this.lastDown == null) {
                        if (this.persist) {
                            this.destroyFeature();
                        }
                        this.createFeature(evt.xy);
                    } else if ((this.lastUp == null) || !this.lastUp.equals(evt.xy)) {
                        this.addPoint(evt.xy);
                    }
                    this.mouseDown = true;
                    this.lastDown = evt.xy;
                    this.drawing = true;
                    return false;
                }
            };
            OpenLayers.Handler.Polygon.prototype.mousedown = function(evt) {
                if (evt.button != 2) {
                    // ignore double-clicks
                    if (this.lastDown && this.lastDown.equals(evt.xy)) {
                        return false;
                    }
                    if (this.lastDown == null) {
                        if (this.persist) {
                            this.destroyFeature();
                        }
                        this.createFeature(evt.xy);
                    } else if ((this.lastUp == null) || !this.lastUp.equals(evt.xy)) {
                        this.addPoint(evt.xy);
                    }
                    this.mouseDown = true;
                    this.lastDown = evt.xy;
                    this.drawing = true;
                    return false;
                }
            };
        }
    [script removed]


Thanks,


Johnny