Add Viewport
methods to find Control
nodes and subwindows at global position
#103929
+42
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative implementation of #86343 based on this comment suggesting that a new
Viewport::gui_find_node_at_position
method be created that mimics the behavior ofViewport::gui_find_control
but returns any blocking subwindows at the position. For easier type handling, this PR splits that suggested method intogui_get_control_at_position
forControl
nodes andgui_get_window_at_position
for embedded subwindows.@cdoise-vbg I don't want to step anyone's toes, so I'm happy to close this if you're still working on that PR.
Use Case: Mimicking/simulating mouse inputs (e.g., a local multiplayer game where each user has their own cursor); creating alternative ways to interact with UI (e.g., throwing a box at a screen).
Partially Adresses: GIP#8408 (allows finding one but not all
Control
nodes at a point).New Methods:
Viewport.gui_get_control_at_position(position, ignore_subwindows)
: Gets theControl
node at the position, optionally including if the node is within an embedded subwindow.Viewport.gui_get_window_at_position(position)
: Gets the embedded subwindow at the position.Outstanding Questions:
Control.mouse_filter
)?Viewport::gui_find_control
should be renamed toViewport::_gui_find_control
, assuming we never intend for developers to use it as a public API? NOTE: I believe this would break any custom modules usinggui_find_control
(of which I've seen at least one).Control
nodes will not behavior as expected.PopupMenu
in particular is weird due to how it handles input and appears to to not actually useButton
s under-the-hood. Is this fine?