2

Can anyone explain how I can ovveride the dblclick event when I'm using an OpenLayers.Control.DrawFeature? I see there is parameter in the constructor for handlerOptions - Used to set non-default properties on the control’s handler. My handler is just an OpenLayers.Handler.Path.

I want to run some custom validation when a user double clicks so that they can continue the sketch should they fail.

Double click --> "you've drawn something stupid are you sure you want to finish?" --> No ---> carry on sketching

Thanks, James

1 Answer 1

1

if you make some edit here OpenLayers / lib / OpenLayers / Handler / Path.js , you can reach what you want.

code:

/**
* APIMethod: finishGeometry
* Finish the geometry and send it back to the control.
*/
    finishGeometry: function() {
        var index = this.line.geometry.components.length - 1;
        this.line.geometry.removeComponent(this.line.geometry.components[index]);
        this.removePoint();
        this.finalize();
    },

    /**
* Method: dblclick
* Handle double-clicks.
*
* Parameters:
* evt - {Event} The browser event
*
* Returns:
* {Boolean} Allow event propagation
*/
    dblclick: function(evt) {
        if(!this.freehandMode(evt)) {
            this.finishGeometry();
        }
        return false;
    }

i hope it helps you...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.