WoW:USERAPI GetCursorScaledPosition

Revision as of 05:59, 24 November 2007 by WoWWiki>Egingell (New page: {{userfunc}} <!-- Leave this line in! --> <center>'''{{PAGENAME}}''' ''- by Egingell -''</center> Returns the scaled position of the cursor. x, y = {{PAGENAME}}() == ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

← User defined functions

USERAPI GetCursorScaledPosition - by Egingell -


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