0 votes

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

in Engine by (398 points)

2 Answers

+1 vote
Best answer

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)
by (1,437 points)
selected by

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

+1 vote

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.

by (719 points)

thank you so much

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.