[OpenLayers-Users] handle right mouse click

PhilM pj_maloney at hotmail.com
Tue Feb 23 06:52:16 EST 2010


I have achieved this by changing the mousedown handler in Handler\Path.js

     mousedown: function(evt) {
	//PhilMaloney - Cancel drawing with right-click
	var rightclick;
	if (evt.which) rightclick = (evt.which == 3);
	else if (evt.button) rightclick = (evt.button == 2);
	if (rightclick) {
		var index = this.line.geometry.components.length - 1;
		this.line.geometry.removeComponent(this.line.geometry.components[index]);
		this.removePoint();
		this.finalize('cancel');
		return false;
	}

        // 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;
    },

Regards
Phil


mario1982 wrote:
> 
> Hi, 
> I'm working on drawFeature.js and Path.js for drawing feature such as
> lines and polygons. How can I handle right mouse click during the feature
> drawing?
> My goal is to find a way to undo the current feature by right mouse
> clicking.
> 
> Thank you for your help.
> Regards,
> 
> Mario
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 
-- 
View this message in context: http://n2.nabble.com/handle-right-mouse-click-tp4614676p4618395.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list