Can I prevent a map tool from deactivating using OnToolDeactivateAsync or OnActiveToolChanged?

346
2
07-11-2023 04:13 PM
JustinLovato
New Contributor

I have a MapTool that I don't want the user to be able to exit out of. I am trying to use the OnToolDeactivateAsync Task and/or the OnActiveToolChanged event to 'reactivate' the tool as soon as the user presses the escape key.

protected override Task OnToolDeactiveAsync(bool hasMapViewChanged)
{
    if (FrameworkApplication.OutgoingTool == "Map_Tool")
    {
        FrameworkApplication.SetCurrentToolAsync("Map_Tool");
    }
    return base.OnToolDeactivateAsync(hasMapViewChanged);
}

After this executes my MapTool is shown as active on the map, but is bugged in functionality - it works similar to that of the Explore Tool. I'm not sure why this is. Is there a way to achieve a re-activation of a MapTool upon its deactivation through this method or other?

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

I see this behavior also. I will post back if I have any updates on this.

Just curious about the workflow you are trying to achieve with the custom tool - How will you zoom, pan, identify, select?    Will your tool handle all the actions?

 

0 Kudos
JustinLovato
New Contributor

Essentially, we want our custom map tool to be the default tool. Unless the user specifically activates another tool we want our map tool to be on. As far as zooming and panning the user is still able to zoom with the mouse scroll and pan by holding c + click and drag. Identify and select is unused though in our tool at this time.

0 Kudos