mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix incorrect transform method reference in CanvasItem.get_screen_transform() documentation
The get_global_transform method of CanvasItem doesn't consider the canvas_transform, so when any camera is enabled, its return value may differ from get_screen_transform. Thus, we should use get_global_transform_with_canvas instead, which provides consistent results with or without cameras enabled.
This commit is contained in:
parent
7ed0b61676
commit
3a61ca9452
2 changed files with 7 additions and 3 deletions
|
|
@ -520,7 +520,7 @@
|
||||||
<return type="Transform2D" />
|
<return type="Transform2D" />
|
||||||
<description>
|
<description>
|
||||||
Returns the transform of this [CanvasItem] in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
|
Returns the transform of this [CanvasItem] in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
|
||||||
Equals to [method get_global_transform] if the window is embedded (see [member Viewport.gui_embed_subwindows]).
|
Equivalent to [method get_global_transform_with_canvas] if the window is embedded (see [member Viewport.gui_embed_subwindows]).
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_transform" qualifiers="const">
|
<method name="get_transform" qualifiers="const">
|
||||||
|
|
|
||||||
|
|
@ -493,10 +493,14 @@
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<description>
|
<description>
|
||||||
Returns the position of this [Control] in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
|
Returns the position of this [Control] in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
|
||||||
Equals to [member global_position] if the window is embedded (see [member Viewport.gui_embed_subwindows]).
|
Equivalent to [code]get_screen_transform().origin[/code] (see [method CanvasItem.get_screen_transform]).
|
||||||
[b]Example:[/b] Show a popup at the mouse position:
|
[b]Example:[/b] Show a popup at the mouse position:
|
||||||
[codeblock]
|
[codeblock]
|
||||||
popup_menu.position = get_screen_position() + get_local_mouse_position()
|
popup_menu.position = get_screen_position() + get_screen_transform().basis_xform(get_local_mouse_position())
|
||||||
|
|
||||||
|
# The above code is equivalent to:
|
||||||
|
popup_menu.position = get_screen_transform() * get_local_mouse_position()
|
||||||
|
|
||||||
popup_menu.reset_size()
|
popup_menu.reset_size()
|
||||||
popup_menu.popup()
|
popup_menu.popup()
|
||||||
[/codeblock]
|
[/codeblock]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue