Addin Tool Deactivate

1958
3
02-10-2014 09:17 AM
KeithSandell1
New Contributor II
I have an addin that includes a Tool. According to the documentation: http://resources.arcgis.com/en/help/main/10.1/index.html#/Tool/014p00000027000000/ there is a function "deactivate" that "Causes the tool to no longer be the active tool."

How do you cause this function to "deactivate" the tool?

At the end of the onMouseDownMap function I need to call the "deactivate" function, i.e. self.deactivate

But the function will not fire until I force the tool to deactivate by clicking another tool manually, which leads me to believe this function is "listening" for deactivation, but is not "causing" deactivation.

The documentation does not help any, nor did a call to support.

class ToolClass3(object):
    """Implementation for CPIC_Territory_addin.tool (Tool)"""
    def __init__(self):
        self.enabled = True
        self.shape = "NONE" 

    def onMouseDownMap(self, x, y, button, shift):
        ##stuff happens here
        self.deactivate

    def deactivate(self):
        self.<make the tool deactivate>

Tags (2)
0 Kudos
3 Replies
JasonScheirer
Occasional Contributor III
In a Python Add-In, calling the deactivate() method WILL NOT deactivate the add-in, only the user can. deactivate() is called to notify the tool class when the user has selected another tool (such as pan, zoom, etc) in the application as a triggered event.
0 Kudos
KeithSandell1
New Contributor II
In a Python Add-In, calling the deactivate() method WILL NOT deactivate the add-in, only the user can. deactivate() is called to notify the tool class when the user has selected another tool (such as pan, zoom, etc) in the application as a triggered event.


So the documentation is wrong?

"Causes the tool to no longer be the active tool."

Then how can I programmatically deactivate the tool at the end of the onMouseDownMap function?
0 Kudos
JohnDye
Occasional Contributor III
Jason is right. You can't.

The documentation is not wrong per-se, it's just misleading.

deactivate() is not a function that's intended for you (the programmer) to leverage. It's a function leveraged by the application so that ESRI tools can deactive it when they are selected. Otherwise, you'd never be able to select another tool.

In order to do what you're trying to do, you'd also need some sort of activate() function in order to default back to another tool like the cursor or pan tool because one tool always has to be active. Currently, there is no programmatic way to switch between tools that I know of.
0 Kudos