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

Add Viewport methods to find Control nodes and subwindows at global position #103929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HuntJSparra
Copy link
Contributor

@HuntJSparra HuntJSparra commented Mar 10, 2025

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 of Viewport::gui_find_control but returns any blocking subwindows at the position. For easier type handling, this PR splits that suggested method into gui_get_control_at_position for Control nodes and gui_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 the Control 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:

  • Should the methods be renamed to indicate they mimic the mouse behavior (i.e., their behavior is affected by Control.mouse_filter)?
  • Should Viewport::gui_find_control should be renamed to Viewport::_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 using gui_find_control (of which I've seen at least one).
  • Some Control nodes will not behavior as expected. PopupMenu in particular is weird due to how it handles input and appears to to not actually use Buttons under-the-hood. Is this fine?

@HuntJSparra HuntJSparra requested review from a team as code owners March 10, 2025 20:38
@HuntJSparra HuntJSparra force-pushed the viewport_find_node_at_position branch from 1357583 to 1676b01 Compare March 10, 2025 20:49
@AThousandShips AThousandShips added this to the 4.x milestone Mar 11, 2025
@HuntJSparra HuntJSparra force-pushed the viewport_find_node_at_position branch from 1676b01 to 96fc5aa Compare March 12, 2025 15:20
@HuntJSparra HuntJSparra force-pushed the viewport_find_node_at_position branch from 96fc5aa to d09a900 Compare March 17, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants