WoW:USERAPI GetCursorScaledPosition: Difference between revisions
Jump to navigation
Jump to search
m (New page: {{userfunc}} <!-- Leave this line in! --> <center>'''{{PAGENAME}}''' ''- by Egingell -''</center> Returns the scaled position of the cursor. x, y = {{PAGENAME}}() == ...) |
m (Move page script moved page USERAPI GetCursorScaledPosition to USERAPI GetCursorScaledPosition without leaving a redirect) |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{userfunc}} <!-- Leave this line in! --> | {{userfunc}} <!-- Leave this line in! --> | ||
Returns the scaled position of the cursor. | Returns the scaled position of the cursor. | ||
x, y = {{PAGENAME}}() | local x, y = {{PAGENAME}}() | ||
== Function Parameters == | == Function Parameters == | ||
=== Returns === | === Returns === | ||
;x | |||
:The scaled x position of the cursor | :The scaled x position of the cursor | ||
;y | |||
:The scaled y position of the cursor | :The scaled y position of the cursor | ||
| Line 24: | Line 19: | ||
==Code== | ==Code== | ||
local function {{PAGENAME}}() | |||
local scale, x, y = UIParent:GetScale(), GetCursorPosition() | |||
function {{PAGENAME}}() | return x / scale, y / scale | ||
end | end | ||
__NOTOC__ | __NOTOC__ | ||
[[Category:User | [[Category:User defined functions]] | ||
Latest revision as of 04:49, 15 August 2023
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.
Returns the scaled position of the cursor.
local x, y = USERAPI GetCursorScaledPosition()
Function Parameters
Returns
- x
- The scaled x position of the cursor
- y
- The scaled y position of the cursor
Example
local x, y = USERAPI GetCursorScaledPosition();
message('('..x..', '..y..')');
Result
- (25.45218785412654, 375.45610597856123)
Code
local function USERAPI GetCursorScaledPosition() local scale, x, y = UIParent:GetScale(), GetCursorPosition() return x / scale, y / scale end