Select to view content in your preferred language

Activate drawTool and start drawing with only one mousedown event

2238
3
06-06-2013 04:51 AM
ab1
by
Deactivated User
Hello,

I'm trying to draw a rectangle on the map using the DrawTool component. I want to start drawing directly after performing a Ctrl + MouseDown.

So in the map_mouseDownHandler function I put the following code:

if(event.ctrlKey){                                              
    // Activate the drawTool
    _context.drawTool.activate(DrawTool.EXTENT);

    // This one seems to be necessary in order to deactivate map pan            
    _context.mapRef.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP)); 

}


But this dosn't work correctly a 100%. After the loading of the map, and only after the loading, It's necessary to perform a Ctrl + MouseDown and then perform a second MouseDown to be able to draw. After this, a Ctrl + MouseDown suffises to start drawing.

Do you have any idea about where the problem could be?

Regards.
Tags (2)
0 Kudos
3 Replies
ab1
by
Deactivated User
Anyone who's tryed to create a selection by rectangle?
0 Kudos
JordanChapman
Emerging Contributor
Anyone who's tryed to create a selection by rectangle?



I saw this when looking through the examples

http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Select_Graphics_within_Extent/01nq0...
0 Kudos
ab1
by
Deactivated User
Thank you for the answer 🙂
In my code I do as in the sample. I add drawTool.activate(DrawTool.EXTENT) in the "Mouse Down" event handler.
But the first time that I perform a mouse down on the map (after the map is loaded), the drawTool doesn't work. It works only after that first time.
Furthermore, I have to dispatch a Mouse Up event in order to prevent the pan from happening.
0 Kudos