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

Introduce Viewport functions for keeping the mouse over state consistent #99890

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

Sauermann
Copy link
Contributor

@Sauermann Sauermann commented Dec 1, 2024

Some users had problems with forwarding input events to SubViewport since #88992, which adjusted a default value and in effect prevented calling gui_input when used without changes.
I still believe, that this change makes mouse-handling more consistent. But this change makes it necessary to give users tools and instructions about how to deal with this new situation.
Previously I did believe, that sending NOTIFICATION_VP_MOUSE_ENTER and NOTIFICATION_VP_MOUSE_EXIT was sufficient (see godotengine/godot-demo-projects#1139), but the MRP of #98003 demonstrates, that this approach still leaves some situations unresolved.

So I want to introduce with this PR two functions, that allow users to notify viewports about the mouse-over state. These two functions take care of all internal state-adjustments.

I discarded #90444 as a solution, because while it automatically handles the mouse-enter-part, users still have no solution for the mouse-exit-part.
I discarded #89868 as a solution, because it is restricted to TextureRect and doesn't provide a generic solution for all potential relevant nodes.

The introduction of these two function with their descriptions could be seen as either a partial or a total fix of issue #97267.

@Sauermann Sauermann force-pushed the fix-vp-mouse-notifications branch from 6537252 to 8ce663f Compare December 1, 2024 10:08
@Sauermann Sauermann force-pushed the fix-vp-mouse-notifications branch from 8ce663f to 8e00035 Compare December 1, 2024 10:22
@Repiteo Repiteo modified the milestones: 4.4, 4.x Jan 20, 2025
@Repiteo Repiteo requested review from a team and groud January 23, 2025 15:10
@akien-mga
Copy link
Member

@eviltrout @SubSage @rakkarage @krdluzni Would some of you be able to test and confirm that this PR would satisfyingly resolve your linked issues?

Note that this requires modifying the project code slightly to use those new methods.

@akien-mga akien-mga requested review from KoBeWi and bruvzg January 30, 2025 22:26
@rakkarage
Copy link
Contributor

thanks. with this pr, adding:

func _ready() -> void:
	_area.input_event.connect(_on_input_event)
	_area.mouse_entered.connect(_viewport.notify_mouse_entered)
	_area.mouse_exited.connect(_viewport.notify_mouse_exited)

fixes the scroll bar not being highlighted while buttons are in 3d.

#98003

@eviltrout
Copy link
Contributor

This does not fix #89757, but over time I have been convinced it's an edge case that most people will not be concerned with, plus there is a workaround that works well. I have closed my issue.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods work correctly.

Probably needs better documentation on how to apply them, but it might be out of scope for class reference. Also the official GUI 3D can be updated to call the new methods and adjusted in a way that makes them useful.

@Repiteo Repiteo merged commit 654b599 into godotengine:master Feb 3, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 3, 2025

Thanks!

@Sauermann Sauermann deleted the fix-vp-mouse-notifications branch February 3, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants