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

is_action_just_released happens twice in _gui_input() #89812

Open
verypleasentusername opened this issue Mar 23, 2024 · 7 comments
Open

is_action_just_released happens twice in _gui_input() #89812

verypleasentusername opened this issue Mar 23, 2024 · 7 comments

Comments

@verypleasentusername
Copy link

verypleasentusername commented Mar 23, 2024

Tested versions

v4.2.stable.official [46dc277] checked only

System information

windows 7 v4.2.stable Compatable rendering

Issue description

i want to clarify that nothing like that happens in is_action_just_pressed() and is_action_pressed() . is it ok? maybe i need to do it by if event.is_action("Click") and Input.is_action_just_pressed("Click"): and it works but its seems like a bug neverless.

Steps to reproduce

func gui_input(event:InputEvent):
    	if Input.is_action_just_released("Click"):
              print("released")

(with click being left mouse button) and look at console after clicking a mouse once.

Minimal reproduction project (MRP)

N/A

@AThousandShips
Copy link
Member

You shouldn't use Input in this method, use the event, this is documented here

@Sauermann
Copy link
Contributor

Based on your description I have tried to replicate the issue, but I was unable to do so. For me "released" is printed only once.

So there seem to be additional setup steps necessary to recreate this behavior. Please provide a minimal reproduction project.

@AThousandShips
Copy link
Member

Sounds like pressing or releasing two different actions on the same frame, would be good to see if the problem is solved by using the correct methods

@KoBeWi
Copy link
Member

KoBeWi commented Mar 23, 2024

The action is not released twice, _gui_input() can be received multiple times per frame for different events, while only one of them will be your action. You should use event.is_action_released() instead. Action methods from Input are best to be used in _process() or _physics_process().

@timothyqiu
Copy link
Member

Releasing the mouse button when moving your mouse reproduces the behavior 😝 Added a print(event) before print("release"):

InputEventMouseButton: button_index=1, mods=none, pressed=false, canceled=false, position=((1037, 564)), button_mask=0, double_click=false
released
InputEventMouseMotion: button_mask=0, position=((1038, 563)), relative=((1, -1)), velocity=((509.684, 149.9071)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
released

Input.is_action_just_released() is checking the overall input state at that point in time.

What you actually want is to check whether event the parameter is a specific event (event.is_action_released()).

@verypleasentusername
Copy link
Author

Sounds like pressing or releasing two different actions on the same frame, would be good to see if the problem is solved by using the correct methods

it does work the intended way. i will try to do MRP today when i'll have free time.

@AThousandShips
Copy link
Member

i will try to do MRP today when i'll have free time.

For what? Does it not work when you use the correct code? You said "it does work"?

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

No branches or pull requests

5 participants