Click and Hold button in Perspective

I would like to use a “click and hold” button to prevent accidentally triggering critical stuff. Such as deleting a entry from a database. I am not using small popups for confirmation but I dont like those since they add more complexity to the interface.

Below is a example i found:

Thank you

1 Like

I would use a normal button with scripts placed in the onMouseDown, onMouseUp, and onMouseLeave Events, in conjunction with a custom property: Button.custom.clickReleased


self.custom.clickReleased = False

# Untested in live environment - might require slight tweaks
def confirm_if_click_held():
    from time import sleep
    if not self.custom.clickReleased:
        # logic here

system.util.invokeAsynchronous(confirm_if_click_held). # note no parens

onMouseLeave AND onMouseUp:

self.custom.clickReleased = True

For the animation, you could even achieve this as well by setting the style class to the animated version which has a duration of your hold time, and set it back to the non animated when not held