Stuart, That was a little more difficult than I though it was going to be... private function searchDrawEnd(event:DrawEvent):void
{
//selectedDrawingIcon = null;
//clearSelectionFilter();
// deactivate the draw tool
event.target.deactivate();
var geom:Geometry = event.graphic.geometry;
clearBuffer();
if (geom is Polygon && GeometryUtil.polygonSelfIntersecting(geom as Polygon))
{
geometryService.simplify([geom], new AsyncResponder(simpResult, null));
function simpResult(item:Object ,spatialRelat:String):void{
var simpGeoms:Array = item as Array;
queryFeaturesGraphical(simpGeoms[0] as Polygon,"esriSpatialRelIntersects",configSearchGraphical[cboLayerGraphical.selectedIndex]);
}
}else{
//create extent around map point to improve search results
if (geom.type == Geometry.MAPPOINT && addTolerance.selected)
{
geom = createExtentAroundMapPoint(geom as MapPoint, pointSearchTolerance);
}
queryFeaturesGraphical(geom, "esriSpatialRelIntersects",configSearchGraphical[cboLayerGraphical.selectedIndex]);
}
var status:String;
var value:String = selectedDrawingIcon.name;
switch (value)
{
case DrawTool.MAPPOINT:
{
status = pointLabel;
drawSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 15, 0x3FAFDC, 1);
break;
}
case DrawTool.POLYLINE:
{
status = lineLabel;
drawSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0x3FAFDC, 1, 1);
break;
}
case DrawTool.EXTENT:
{
status = rectangleLabel;
drawSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, 0x3FAFDC, 0.5, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0x3FAFDC, 1, 1));
break;
}
case DrawTool.POLYGON:
{
status = polygonLabel;
drawSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, 0x3FAFDC, 0.5, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0x3FAFDC, 1, 1));
break;
}
}
setMapAction(value, status, drawSymbol, searchDrawEnd);
}
Your problem is going to be deactivating. If you close the widget or choose another tool it will deactivate.