Force Mouse To be Unpressed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LoneDespair

Hi there i am just wondering if it possible to forcefully make a pressed mouse to be unpressed via script, i really need it for the swipe logic of my game wherein i need to forcefully unpress the touch event after a period of time

thanks in advance

:bust_in_silhouette: Reply From: wyattb

Just run the swipe logic after the given time and ignore user input. It’s almost like asking to un-press a keyboard press. Unless your mouse has the ability to shock the user to releasing it. That’ll teach em.

thank you so much

LoneDespair | 2019-11-09 14:51

:bust_in_silhouette: Reply From: Adam_S

You can use Input.parse_input_event() for this.
For the left mouse button it would look like this:

func release_left_mouse_button():
    var a = InputEventMouseButton.new()
    a.set_button_index(1)
    a.set_pressed(false)
    Input.parse_input_event(a)

Sorry for super late reply hahaha, thanks for your help, it really helped me a lot

LoneDespair | 2019-11-09 14:49