WoW:API GetCursorPosition: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
m (Move page script moved page API GetCursorPosition to API GetCursorPosition without leaving a redirect)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<center>'''GetCursorPosition''' ''-Documentation by Kolth-''</center>
{{wowapi}} __NOTOC__


Returns the cursor's position on the screen.
Returns the cursor's position on the screen.


GetCursorPosition();
GetCursorPosition();
 
----
;''Arguments''


== Arguments ==
:''none''
:''none''


----
== Returns ==
;''Returns''


:;x : Number - The cursor's x-position on the screen.
:;x : Number - The cursor's x-position on the screen.
:;y : Number - The cursor's y-position on the screen.
:;y : Number - The cursor's y-position on the screen.


----
== Example ==
;''Example''
   local x, y = GetCursorPosition();
   local x, y = GetCursorPosition();


;''Result''
=== Result ===
  x = 956.24999166082;
  x = 956.24999166082;
  y = 538.49999965651;
  y = 538.49999965651;


----
== Details ==
;''Description''
 
: Returns scale-independant coordinates similar to Cursor:GetCenter() if 'Cursor' was a valid frame.


----
: Returns scale-independent coordinates similar to Cursor:GetCenter() if 'Cursor' was a valid frame. You can use this value relative to UIParent if you treat BOTTOMLEFT as 0,0. Remember to also apply scale.


{{template:WoW API}}
== Notes ==
: To apply scale, divide both x and y by the value returned by UIParent:GetEffectiveScale()
: The coordinates returned by this use BOTTOMLEFT as the origin, not TOPLEFT. This means [0, 0] is the exact bottom-left point on the screen.

Latest revision as of 04:45, 15 August 2023

WoW API < GetCursorPosition

Returns the cursor's position on the screen.

GetCursorPosition();

Arguments[edit]

none

Returns[edit]

x
Number - The cursor's x-position on the screen.
y
Number - The cursor's y-position on the screen.

Example[edit]

 local x, y = GetCursorPosition();

Result[edit]

x = 956.24999166082;
y = 538.49999965651;

Details[edit]

Returns scale-independent coordinates similar to Cursor:GetCenter() if 'Cursor' was a valid frame. You can use this value relative to UIParent if you treat BOTTOMLEFT as 0,0. Remember to also apply scale.

Notes[edit]

To apply scale, divide both x and y by the value returned by UIParent:GetEffectiveScale()
The coordinates returned by this use BOTTOMLEFT as the origin, not TOPLEFT. This means [0, 0] is the exact bottom-left point on the screen.