-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Expose viewport gui_find_control
to scripting
#86343
base: master
Are you sure you want to change the base?
Conversation
gui_find_control
gui_find_control
gui_find_control
to scripting
The bind methods aren't just exposed to GDScript, they're also available to C# and GDExtension, please update your commit message accordingly |
This example will not work when the Canvas layer has a non-default transform, since you are mixing different coordinate systems:
Please change your description to: var control_under_point = get_viewport().gui_find_control(get_viewport().get_mouse_position()) |
Thank you for the feedback. I'll work on updating the description. Two
scenarios I was interested in supporting with this are:
- Second player with a custom gamepad-controlled virtual cursor being able
to click on Controls.
- Testing logic that can do basic checks for the presence of a Control at a
particular coordinate on-screen.
…On Tue, Dec 19, 2023 at 8:29 PM Markus Sauermann ***@***.***> wrote:
var control_under_point =
get_viewport().gui_find_control(get_global_mouse_position())
This example will not work when the Canvas layer has a non-default
transform, since your are mixing different coordinate systems:
- CanvasItem.get_global_mouse_position() returns the position in
canvas layer coordinates
- Viewport.gui_find_control() accepts the position in viewport
coordinates.
Please change your description to:
var control_under_point = get_viewport().gui_find_control(get_viewport().get_mouse_position())
—
Reply to this email directly, view it on GitHub
<#86343 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATYQEV2YOZLEJFKUPYFX3J3YKI5QDAVCNFSM6AAAAABA33EBWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRTG4YDAOBWGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I updated the description to be more specific about which coordinates are expected based on comments above. Should I include the specific code example too in that particular comment location? (meaning: "var control_under_point = get_viewport().gui_find_control(get_viewport().get_mouse_position())"). I also need to go back and fix up the 2 commits so that they appear as 1. UPDATE: |
… called from places that can make use of the bound methods (such as GDScript, C#, and GDExtension).
doc/classes/Viewport.xml
Outdated
<param index="0" name="point" type="Vector2" /> | ||
<description> | ||
Returns the [Control] that would be under the mouse cursor if the mouse cursor were located at the | ||
viewpoint coordinates provided by the point parameter. If no [Control] is at that point, returns null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viewpoint coordinates provided by the point parameter. If no [Control] is at that point, returns null. | |
viewport coordinates provided by the point parameter. If no [Control] is at that point, returns null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be a single line, the current text is two separate paragraphs
Updating documentation wording for gui_find_control to be clearer and to remove extra whitespace. Co-authored-by: A Thousand Ships <[email protected]>
Thank you @AThousandShips for the rewording of the documentation. I've committed that from the button to accept suggested changes in the comments above. Should I now go back and squash those two commits back down to one? |
@AThousandShips will this pull reqest be merged? |
It hasn't been approved yet, only once approved will it be considered for merger, we're currently in feature freeze for 4.3 so this can't be merged until after 4.3 has been released, but again after approval |
Do I need to do anything in particular to request approval or further comments for the latest check-in from December 31? |
Not that I know, but once 4.3 has been released you can write in the developer chat and see if anyone can take a look, feel free to join already to keep up to date with development |
I fixed the conflict and did a quick test with an editor script and this seemed to work fine and as expected. You may want to squash the commits again to 1 and fix the conflict. |
Please note, that So I'm not sure, if exposing this function as it is, is a good idea, because people could get unexpected results, if they are unaware of these details. This implementation detail also caused problems inside the engine, which was recently discovered: see #99849 Would the following idea be better?
|
Resubmitting relevant changes from this pull request to expose gui_find_control to GDScript. Another pull request had already been merged in that covered getting the mouse_over control
#84909
Usage: