godot: Button is not pressed by InputEventScreenTouch when Emulate Mouse From Touch is disabled in the Project Settings
Godot version: 3.0.6
OS/device including version: windows 10 pro / GT 1030 gpu
Issue description: In the script extending button, when using _gui_input() and InputEventScreenTouch, it does not cause the button to be pressed down. Visually also the button does not go button_down.
Steps to reproduce: Create a button, and in the code do:
func _gui_input():
if event is InputEventScreenTouch and event.is_pressed():
self.pressed = true
// Also if you connect the pressed() signal with this button, it will not trigger the signal when self.pressed = true. Visually the button does not go down and it does not trigger the Pressed() signal. HOWEVER, IF THE BUTTON IS SET TO TOGGLE MODE, IT WILL REGISTER THE BUTTON AS PRESSED CORRECTLY
Minimal reproduction project: InputEventScreenTouch Bug.zip
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 4
- Comments: 43 (22 by maintainers)
Commits related to this issue
- fix error caused by orphaned released events. I've turned "Emulate Mouse From Touch" off in the Godot settings and for some reason, Button controls like to steal/consume the initial touch pressed eve... — committed to Splizard/Godot-Touch-Input-Manager by Splizard 2 years ago
- fix error caused by orphaned released events. I've turned "Emulate Mouse From Touch" off in the Godot settings and for some reason, Button controls like to steal/consume the initial touch pressed eve... — committed to Splizard/Godot-Touch-Input-Manager by Splizard 2 years ago
- fix error caused by orphaned released events. I've turned "Emulate Mouse From Touch" off in the Godot settings and for some reason, Button controls like to steal/consume the initial touch pressed eve... — committed to Federico-Ciuffardi/GodotTouchInputManager by Splizard 2 years ago
I think UI controls not working with touch controls is a problem.
Yes. You’re right. However, I do not consider that a reliable way to test your input, because although it’s emulating a touch, there are slight discrepancies which could affect the behavior. For example, after pressing and holding your finger down, if you move it at all, godot interprets that as a release, I think. It’s behaving very strangely and I can’t get it to work.
I agree with you. I was just worried maybe I was wrong and I looked dumb. I am pretty sure when I look back though, it really wasn’t working properly as it should.
This issue explains why I couldn’t get
SplitContainer
s working on Android whenEmulate mouse from touch
was disabled. AreControl
nodes really not useable with touch input? This seems like a massive oversight given how expansive and full-featured the UI building nodes are in Godot. Surely using multi-touch in combination with UI isn’t that rare a use case?TouchScreenButton
is obviously useful for buttons, but what about all the otherControl
nodes?Also is this documented anywhere? I can’t recall seeing mention in the documentation of requiring
Emulate mouse from touch
to be enabled to useControl
nodes in your project.Look into using TouchScreenButton nodes for this use case (instead of Button).
the
InputEventScreenTouch
is occurred once only touch start or end. when holding down,InputEventScreenDrag
event occurs.if you want to check it, I would suggest you to use a variable to save its state.
does it help?
I have same/similar issue. I switch off “emulate mouse from touch” so that I can handle selecting objects in 3D space by tapping on them (collision shape + _input_event function). That works, but I now can’t use any of the standard UI controls. Not even LineEdit.
No need to open a new issue – I think it’s the same underlying issue.
This actually may be the crux of my issue! I definitely turned off
Emulate Mouse From Touch
, because I want to be able to grab multi-touch and swipe/drag inputs. I’ve also turned onEmulate Touch From Mouse
, and have no issue pressing the buttons while running locally with that option enabled. Did I perhaps misunderstand the intent of the former option?It looks like this already exists!
device
inInputEvent
is set to-1
(InputEvent::DEVICE_ID_EMULATION
internally) when the input is emulated. This seems to be true for both emulated mouse events and emulated touch events, but the docs only mention that this is the case for emulated mouse events, so that should probably be updated.This allows for a new workaround:
Which is good enough for me.
In my case, this falls apart because I’m building a multi-platform game with multiple viewports, which needs to support both touch and mouse, including pinch zoom on touch devices. I had hoped to leverage the rich UI library offered by Godot, but it seems that in order to do this I either need to take away multitouch functionality or build my own UI controls from scratch.
I imagine I’m not alone in wanting to use a rich UI in combination with multitouch gestures, but perhaps most users aren’t building for multiple platforms.
While this is still a problem, I have worked around it myself by leaving “Emulate Mouse From Touch” enabled and capturing mouse events instead. I can capture the swipes I’m interested in this way. Probably not good enough if you want to capture multiple finger swipes at the same time, but I’m not doing that.
Hi, I created this ticket like a year or two ago. Been following the updates on this issue. In all fairness, I was pretty new to godot when I first used it. I probably could find a workaround easily now with my experience. Maybe I was just doing something wrong, or maybe it actually was a problem.
Reading the source, it seems to me that indeed there is only mouse integration for button pressing. From the OP:
From my own experience, when
Emulate Touch From Mouse
is off, this is true. Thepressed
signal is not fired, and no visual element of the button is interacted with. I’m not sure if this observation and tighter scoping of the issue with worth filing a new GitHub Issue, what do you think? It does seem at least loosely related, and even if the behavior is intended, some documentation on the subject would be great. It’s kind of baffling to me that your only option for interacting with menus in Godot on mobile is to emulate mouse behavior.This might be happening due to touch release events not being sent. Similar to #16761, #41585
This issue should be redefined as an enhancement to the
BaseButton
class that lets it also detect theInputEventScreenTouch
event in_gui_input