-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Disabling "Embed Subwindows" breaks manual input sent via get_viewport().push_input()
in Godot 4.4
#103361
Comments
Seems a regression between 4.4 dev 2 and 4.4 dev 3, bisecting. |
Bisected to #93500, CC @anniryynanen |
Oh dear. I wish I could look into this but I don't have the capacity at the moment. #93500 has an updated MRP that should make it easy to test that the fix to this issue doesn't regress that fix. |
The issue is, that #93500 was implemented under the assumption that mouse-button presses only activate a Button node, if the mouse is hovering the button. With your MRP, this fails, when the mouse is not over the first button. (Try selecting the second button, moving the mouse over the first button and activating the second button with the "space" key on the keyboard in your MRP) Workaround 1: Workaround 2: Workaround 3: Conceptional problem: Proposed solution: |
Thank you so much for the quick responses and suggestions! I believe workaround 1 should work for us, but the others don't. The reason why we need it (and why I think this should remain supported) is that we use it to implement an alternative input method. It's a projector (which projects a separete window of the game, which is why we need "Embed Subwindows" at false) with a camera, where the camera is accessed by a Python program to detect objects on the surface which the projector projects to. It essentially behaves like a touchscreen; placing objects onto the projection should generate inputs. But since we want to control the main window of the game with mouse and keyboard at the same time as this projector-camera input method is used, we can't send OS-level mouse input, but instead send WebSocket messages to our Godot game. The game turns these messages into InputEvents. That way, all our UI is controllable with this funky input method (while still being able to debug it with a mouse if needed), and mouse-keyboard input in the other window is unaffected. That might be too abstract to imagine the use-case, so here is a bit more detail: the separate window which is projected and interacted with through objects detected by a camera displays a map. Objects represent things to be placed on that map (e.g. a wind turbine). The main window is a 3D visualization of the same map section. Here's a video of what I'm talking about: https://landscapelab.boku.ac.at/videos/wka_placement.mp4 So I do think that manually creating "click" inputs for controlling the UI has its legitimate use-cases with alternative input methods. |
I don't believe @Sauermann's workaround 1 works, unless I'm doing something wrong. This is the code I added before the click events: var motion_event = InputEventMouseMotion.new()
motion_event.position = Vector2(200, 50)
motion_event.global_position = Vector2(200, 50)
get_viewport().push_input(motion_event, false)
await get_tree().process_frame This does not change any behavior. extends Button
func _input(event):
if event is InputEventMouseButton and event.pressed:
if get_global_rect().has_point(event.position):
pressed.emit()
get_viewport().set_input_as_handled() This makes sense, since it bypasses the button's own logic. But this also means that it doesn't replicate some of the usual behavior (check visibility, grab focus, change visual appearance, etc.) |
Tested versions
System information
Tested on Arch Linux (KDE) and Windows 11
Issue description
I manually create an
InputEventMouseButton
and push it viaget_viewport().push_input
to press a GUI button. The button is pressed as expected on Godot 4.3 and earlier, as well as on Godot 4.4 as long as the "Embed Subwindows" option is enabled in the project settings.However, when "Embed Subwindows" is disabled, the behavior is strange since Godot 4.4: the button does not react to the pushed input, even though the "Misc" panel in the Debugger correctly identifies the last clicked control as the Button.
The button neither reacts visually nor does it emit signals in this case.
Steps to reproduce
We manually create mouse clicks like this:
The position must correspond to the location of a UI element. With "Embed Subwindows", the UI node at the corresponding location is pressed as expected by this code. But without "Embed Subwindows", the UI does not react to the manually created event (even though it does react to a normal mouse click).
Minimal reproduction project (MRP)
viewport-input-test.zip
Pressing the "hallo" button manually prints "hallo".
Pressing the "press the other button" button causes the "hallo" button not to be pressed, even though it should be. When setting
window/subwindows/embed_subwindows
totrue
(either in the project settings GUI or in project.godot), "press the other button" does cause "hallo" to be pressed, printing "hallo" to the output.The text was updated successfully, but these errors were encountered: