2

I am using the Draw Toolbar in the Esri Javascript API v3.4 and connecting to the onDrawEnd event using aspect.after(drawingToolbar, "onDrawEnd", drawEndHandleFunction, true);

I am using the Draw Toolbar with the EXTENT tool to allow my user to select features by drawing a box around them. So far it is working fine. However, I want the user to be able to add and subtract features from the selection using the CTRL and SHIFT keys while drawing.

I was able to do this in Chrome using the event.ctrlKey and event.shiftKey properties of the event global variable. Firefox does not appear to have an event global variable like this and so my function doesn't work. Firefox apparently passes an event as a parameter in the function, but that is not available because I used dojo/aspect.

Is there a better way to handle this? Otherwise is there a way to get a map mouse event that triggers the onDrawEnd event in the Draw Toolbar?

2

Have a look at this : http://dojotoolkit.org/reference-guide/1.8/dojo/keys.html?highlight=keys#id2

There are some good Samples for Key-Eventlistener. Maybe it's useful.

Here's how i manage to listen for the EnterKey in a Textbox. I use the new dojo 1.8

require(["dojo/keys","dojo/dom","dojo/on"], function(keys, dom, on){
        on(dojo.byId("selectAnlagenNummer"), "keypress", function(evt){
            var charOrCode = evt.charCode || evt.keyCode;
            if (charOrCode == keys.ENTER) {
                zoomToAnlage();
            }
        });
    });

It's not a complete solution for your Problem, but maybe it shows a way.

1

Attach to the keydown and keyup events. When the "draw-end" event fires use the "IsShiftDown" to see if the shift was being held down.

require(["dojo/on", "dojo/domReady!"], function(on) {

    var IsShiftDown = false;

    on(document, "keydown", function(event) {
        if(event.keyCode == 16)
           IsShiftDown = true;
    });

    on(document, "keyup", function(event) {
        if(event.keyCode == 16)
           IsShiftDown = false;
    });

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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