Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when the mouse is moving quickly and clicked, the click event is triggered twice #80158

Closed
Az-qianchen opened this issue Aug 2, 2023 · 1 comment · Fixed by #80185
Closed

Comments

@Az-qianchen
Copy link

Godot version

4.1.1

System information

WIn 11

Issue description

I encountered a strange problem - when the mouse is moving quickly and clicked, the click event is triggered twice.

I tried left click, right click, and middle click, they all have the same problem.

I also tried replacing the mouse but still got the same error no matter using is_action_just_pressed or is_action_just_released.

2023-08-02.163929.mp4

Steps to reproduce

mouse is moving quickly and clicked

Minimal reproduction project

mouse.zip

@Sauermann
Copy link
Contributor

Can you please try to use

func _input(event: InputEvent) -> void:
	event.is_action_pressed(...)
		print("1")

See https://docs.godotengine.org/en/latest/classes/class_inputevent.html#class-inputevent-method-is-action-pressed

Input.is_action_just_pressed accesses the global state.

What happens for you is, that in the same frame you get a InputEventMouseButton and a InputEventMouseMotion and for both Input.is_action_just_pressed evaluates to true, because in this frame the mouse-button-event has happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants