godotengine / godotengine/godot
On the _input() function the TouchScreenButton's is_pressed() function returns reversed if called by itself
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- reproducible in: v4.2.1.stable.official [b09f793f5]
### System information
Godot v4.2.1.stable - Android - Vulkan (Mobile) - integrated Adreno (TM) 618 - (8 Threads)
### Issue description
Calling a TouchScreenButton's is_pressed() function returns false when pressed and true when released if by called itself on the _input() function, it works the way I expected if called on the _unhandled_input() function or if called by a parent node.
I tested on a button and it works the way I expected, true when pressed and false when released.
I was making a custom TouchScreenButton and using _unhandled_input() is not ideal because I wanted to handle the input, calling from a parent node works but thats not ideal because that makes my scene a little more complex as I need an extra node I wouldn't need otherwise.
### Steps to reproduce
- Add a TouchScreenButton
- Add a script to it
- On the _input() function check if the event is a InputEventScreenTouch
- if it is call is_pressed()
- the return value will be reversed, false when pressed and true when released
### Minimal reproduction project (MRP)
[test2.zip](https://github.com/godotengine/godot/files/14393796/test2.zip)
Contributor guide
Research direction
Start with the attached minimal reproduction project and the TouchScreenButton _input() and is_pressed() entry points. Compare behavior when the same InputEventScreenTouch is handled in _input(), _unhandled_input(), and from a parent node. Done means is_pressed() reports true while the touchscreen button is pressed and false after release when checked from _input().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100