Deactivate a map tool on sketch completed

321
2
Jump to solution
11-19-2017 03:03 AM
Highlighted
Occasional Contributor II

I have a problem with deactivating my custom map tool when sketch is finished.

At now I'm trying to call SetCurrentToolAsync from the OnSketchCompleteAsync of my map tool. But this causes deadlock. Seems like I need to exit from OnSketchCompleteAsync to proceed with changing the current tool.

I want to deactivate the tool when sketch is completed. I didn't found any property in the MapTool class to specify this behavior. Is this possible?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Regular Contributor

Max,

Try setting the applications current tool to null (or anything else).

If its null then 'explore' mode will be active.

    protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
    {
      //do something productive with the sketch and deactivate
      ArcGIS.Desktop.Framework.FrameworkApplication.SetCurrentToolAsync(null);
      return base.OnSketchCompleteAsync(geometry);
    }

View solution in original post

0 Kudos
2 Replies
Highlighted
Esri Regular Contributor

Max,

Try setting the applications current tool to null (or anything else).

If its null then 'explore' mode will be active.

    protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
    {
      //do something productive with the sketch and deactivate
      ArcGIS.Desktop.Framework.FrameworkApplication.SetCurrentToolAsync(null);
      return base.OnSketchCompleteAsync(geometry);
    }

View solution in original post

0 Kudos
Highlighted
Occasional Contributor II

Hi Sean,

Hmm, seems it works. I marked this method as async and used await for SetCurrentToolAsync, but it caused deadlock somehow.

Thank you!

0 Kudos