How I can do event with two clicks using python add-in wizard, I have found a way to do event with one click by adding a New Tool in the wizard, but I need "first click To copy the attributes from the features and in the second to update another feature"? Can I use (def onMouseDownMap(self, x, y, button, shift)) twice on the same tool?


Yes you can, you could do it by adding a global variable that keeps track of your clicks. For example:

class ToolClass2(object):
"""Implementation for Test_addin.tool (Tool)"""
def __init__(self):
    self.enabled = True
    self.shape = "NONE"
    global clickCount
    clickCount = 0
def onMouseDownMap(self, x, y, button, shift):
    global clickCount
    if clickCount == 0:
        # Your code for the first click
        clickCount = 1
    elif clickCount == 1:
        # Your code for the second click
        clickCount = 0 # Resets to first click behaviour after every second click

Have you also considered using left click for the first action, and then right click for the second? Or a key combination with the click? Because those are also possible options to achieve multiple actions with one tool.

See the ESRI documentation for options regarding mouse buttons and keyboard keys.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.