[Fixed] "'<invalid type>' object is not callable" when trying to access canvas mouse events

What I’m trying to do:
Access the event arguments (x, y, button, etc…) from a canvas mouse event.

What I’ve tried and what’s not working:
Tried to make simple use the argument values (such as subtracting from ‘x’ and ‘y’, checking the value of ‘button’), however I am receiving a ‘TypeError’ by doing so.

It only seems to work when converting to a string and back. It used to work previously, however this week I’ve suddenly been receiving the error.

Code Sample:

def canvas_1_mouse_down(self, x, y, button, keys, **event_args):
    """This method is called when a mouse button is pressed on this component"""
    
    print(x)
    print(y)
    print(button)

    # Not working:

    print(f"X minus 50 is {x - 50}")
    print(f"Y minus 50 is {y - 50}")
    print(f"Button {button} clicked...")
    if button == 1:
        print("Left mouse")
    elif button == 3:
        print("Right mouse")

    # Only seems to work with type conversion as shown below...

    # print(f"X minus 50 is {float(str(x)) - 50}")
    # print(f"Y minus 50 is {float(str(y)) - 50}")
    # print(f"Button {int(str(button))} clicked...")
    # if int(str(button)) == 1:
    #     print("Left mouse")
    # elif int(str(button)) == 3:
    #     print("Right mouse")

Clone link:
share a copy of your app

Thanks for reporting. We’ll get that fixed.

This should now be fixed.

2 Likes