Click and Hold button in Perspective

Hi,
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:
http://sonsoleslp.github.io/react-click-n-hold/

Thank you
Jakub

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

onMouseDown:

self.custom.clickReleased = False

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

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

onMouseLeave AND onMouseUp:

self.custom.clickReleased = True
2 Likes

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