[OpenLayers-Users] Call function before control activate

soatley shawn at niagarafalls.ca
Thu Jul 9 16:36:50 EDT 2009


I can't seem to find a way to call a function before a control is activated. 
What I am trying to do is record the currently active control before
activating the new control.  That way, when the control is done executing,
the previous control can be re-activated.  

This would be useful for tools that perform a function on click and then
they are done (for example, clear all selections on a layer).

I have tried checking what control is active when the new control.activate
is fired, but by that time, the old control seems to have been decativated
because it's active property is set to false.  By extending a control (see
code below) it executes when the control is created, but not activated.


clearSelectionControl = new OpenLayers.Control({ title: "Clear any
selections", displayClass: "olControlClearSelection" });
OpenLayers.Util.extend(clearSelectionControl, {
    draw: function() {
        this.box = new OpenLayers.Handler.Box(clearSelectionControl,
    { "done": this.notice,
        "activate": this.makeActive
    });
        log("checking active control");
        for (var c in map.controls) {
            if (map.controls[c].active == true) {
                log(map.controls[c].displayClass + ": " +
map.controls[c].active);
            }
        }
        log("done checking");
    },

    notice: function(bounds) {
        log("firing notice");
    }
});

Can anyone think of a way to do this?


Shawn
-- 
View this message in context: http://n2.nabble.com/Call-function-before-control-activate-tp3233944p3233944.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list