atadenizoktay / godot-click-through-transparent-window

A demo project for the Godot Engine that features a transparent window with click-through capability.
https://atadenizoktay.itch.io/godot-cttw
MIT License
42 stars 1 forks source link

Godot Question #3

Open spiritfoxx opened 9 months ago

spiritfoxx commented 9 months ago

Hello, I came across your neat project. I wanted to know if it was possible to use mouse_passthrough in place of mouse_passthrough_polygon used in your function here. I am confused why mouse_passthrough has no effect.

## Updates the clickable area, preventing inputs from passing through the
## window outside of the defined region.
func _update_click_polygon() -> void:
    var click_polygon: PackedVector2Array = _ClickPolygon.polygon
    for vec_i in range(click_polygon.size()):
        click_polygon[vec_i] = to_global(click_polygon[vec_i])
    get_window().mouse_passthrough_polygon = click_polygon

Godot Docs Description of the Property

https://docs.godotengine.org/en/stable/classes/class_window.html#property-descriptions screenshot

atadenizoktay commented 8 months ago

Hello @spiritfoxx ,

In its definition, it says that mouse_passthrough, when true, will pass mouse events to the underlying window of the same application. I think it is referring to a multiple-window application layout by this rather than passing inputs directly to the OS by ignoring the whole Godot application you create, which I believe is the feature you seek.

I remember having similar trouble in the past, but in the end, I was not able to find a solution I was satisfied with so created this repository and utilized polygons to achieve almost the same behavior.

I wish I could be more helpful. Please let me know if you find anything useful regarding this situation!

spiritfoxx commented 8 months ago

Hello again,

I am aware of OS.set_window_mouse_passthrough, which you have used in godot 3. I'm trying to figure out how to have the mouse passthrough for the entire window. You said you had trouble in the past, I'm guessing mouse_passthrough_polygon is the only way to acomplish that in godot 4.

atadenizoktay commented 8 months ago

I just realized that I've used OS.set_window_mouse_passthrough in the Godot 3 branch of this project after you said it. I checked the docs for Godot 3 and understood that OS.set_window_mouse_passthrough was replaced with Window.set_mouse_passthrough_polygon and mouse_passthrough property is a new addition.

I believe the mouse_passthrough_polygon property is the way to go regarding our situation, and mouse_passthrough is added as a new property in accordance with the multi-window application support that came with Godot 4. Here is the official news concerning that update.

Nevertheless, please let me know if you find an alternative solution in the future. Thank you for opening this issue!