How can I click through the screen while keeping a transparent screen?

Godot Version

4.2.1

Question

First of all, this is my code.

func _ready():
DisplayServer.window_set_mouse_passthrough($Path2D.curve.get_baked_points())
DisplayServer.window_set_mouse_passthrough()
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_TRANSPARENT, true)

Now when I run this, the screen becomes transparent, but the click doesn’t through the screen

2 Likes

I searched the web a lot, and ended up finding this solution. It seems like a terrible workaround, but it allows you to click through. I think it works by making the game window the same size as the object you pass into the method.

1 Like

i’ve been trying to figure this out as well. I’ve adjusted a lot of project settings, but cannot figure it out yet
background

Hey guys, this is by no mean a definite answer (I guess, because I do not test it extensively), but I made a small script that reads from a control node assigned to a group to determined clickable regions

func _process_clickables() -> void:
	var clickable_nodes = get_tree().get_nodes_in_group("Clickables")
	for node in clickable_nodes:
		if node is Control:
			var rect = node.get_rect() as Rect2
			var texture_corners: PackedVector2Array = [
			rect.position, # Top left corner
			rect.position + Vector2(rect.size.x, 0), # Top right corner
			rect.position + rect.size, # Bottom right corner
			rect.position + Vector2(0, rect.size.y) # Bottom left corner
			]
			
			DisplayServer.window_set_mouse_passthrough(texture_corners)
		else:
			printerr(node.name + " is not a Control")

here is a demo

demo

Edit: Dont forget to call the function on the process method so every tick every clickable is recalculated

1 Like

Do I need to put the project window on always on top ?

Do you have the project working? I tried your code here and the window disappears unfortunately

It’s not perfect, but: you need to turn off “Embed subwindows” in project settings (Display → Window → Subwindows → Embed Subwindows, when Advanced Settings turned on (top right in settings window) (or just search)). Also make sure to enable Borderless, Transparent and Per Pixel Transparency. So, you will need to put objects in Window nodes with Borderless and Transparent flags. To move objects you can change position property of windows. Your objects will have a rect box (by default) around them that you can’t click through (you can change rect box into any shape, modifying mouse_passthrough_polygon property of a Window node) :3