WoW:USERAPI GetCursorScaledPosition
Jump to navigation
Jump to search
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.
x, y = USERAPI GetCursorScaledPosition()
Function Parameters
Arguments
- nil
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
function USERAPI GetCursorScaledPosition()
local scale = UIParent:GetScale()
local x, y = GetCursorPosition()
if scale == 0 then -- very little to no chance of this happening, but you never know.
return
else
return x / scale, y / scale
end
end