Skip to content
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

Embedded window doesn't emit mouse_exited / mouse_entered. #66293

Closed
rambda opened this issue Sep 23, 2022 · 1 comment · Fixed by #67791
Closed

Embedded window doesn't emit mouse_exited / mouse_entered. #66293

rambda opened this issue Sep 23, 2022 · 1 comment · Fixed by #67791

Comments

@rambda
Copy link

rambda commented Sep 23, 2022

Godot version

4.0.beta1

System information

Windows 10

Issue description

Embedded window doesn't emit Window.mouse_exited or Window.mouse_entered when the player move the mouse into or out of the window's area. (Embedded window meaning its parent viewport has gui_embed_subwindows = false.)

Non-embedded windows will correctly emit both signals.

Also, both the embedded window and its parent will emit Window.window_input(event), as if they're a same window - which is technically right on the OS level. So it might not be a bug.

If it's not a bug, how do we check if the mouse exited an embedded window?

Steps to reproduce

See reproduction project.

Minimal reproduction project

mouse_exited.zip

@Calinou Calinou added this to the 4.0 milestone Sep 24, 2022
@Calinou Calinou moved this to To Assess in 4.x Priority Issues Sep 24, 2022
@Sauermann
Copy link
Contributor

Sauermann commented Sep 26, 2022

From what I can tell, this is a missing feature. Currently embedding Viewports do not keep track, over which embedded Window the mouse is. Adjustments would need to be made to Viewport::_sub_windows_forward_input in order to implement this.

You could try in your MRP as a workaround something like this in the meantime (warning: contains inaccuracies, not for production):

var overW2 = false
func _on_window_window_input(event: InputEvent) -> void:
	if name == "Window2" and event is InputEventMouse:
		var r = Rect2i(Vector2i(0,0), size)
		var pos = event.position
		var inside = r.has_point(pos)
		if overW2 and (not inside):
			overW2 = false
			print("now outside W2")
		elif (not overW2) and inside:
			overW2 = true
			print("now inside W2")

Also, both the embedded window and its parent will emit Window.window_input(event), as if they're a same window - which is technically right on the OS level. So it might not be a bug.

If you look closely, you will see that for a single Mouse event output shows different coordinates for the embedding window and the embedded window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants