Thread Tools Display Modes
08-19-10, 07:13 PM   #1
vlakarados
An Aku'mai Servant
 
vlakarados's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 36
GetCursorPosition relative position

GetCursorPosition() gives you coordinates relative to BOTTOMLEFT part of the screen, how to make it show them from another position?

I've tried finding how I can get numbers similar to GetCursorPosition() ones with calculations of screen size and UI scale, something like
Code:
local hor, ver = strsplit("x", ({GetScreenResolutions()})[GetCurrentResolution()])
		print(hor .. " and " .. ver)
		print(hor/UIParent:GetEffectiveScale() .. " / " .. ver/UIParent:GetEffectiveScale())
		print(hor*UIParent:GetEffectiveScale() .. " * " .. ver*UIParent:GetEffectiveScale())
but it shows different numbers, currently I have 1280x1024 but this code gives me
Code:
[04:08:58] 1280 and 1024
[04:08:58] 1560.9756233719 / 1248.7804986975
[04:08:58] 1049.5999908447 * 839.67999267578
but GetCursorPosition gives me 1169.8 and 936.6 when divided with UIParent:GetEffectiveScale() when I put my mouse in the TOPRIGHT edge, so none of these numbers are correct...
My UI scale is 0.81999999284744

can someone please help me understand and find a way to do this?
  Reply With Quote
08-19-10, 08:23 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's because the units of UI object dimensions in WoW are not actually pixels.

Run:
/run print(UIParent:GetWidth(), "x", UIParent:GetHeight())

It won't say "1280 x 1024".

If you really wanted to use the resolution to place UI objects, you'd need to figure out the ratio of actual pixels (eg. screen resolution) to "WoW pixels" (eg. UIParent dimensions).
  Reply With Quote
08-20-10, 04:56 AM   #3
vlakarados
An Aku'mai Servant
 
vlakarados's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 36
Thank you very much, you are a genius. I didn't have a good night sleep for a while so I'll blame that as a reason not thinking of this
No, I don't need the resolution then, I hope I will manage to make what I have in mind with GetWidth/Height then. Thank you very much again!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetCursorPosition relative position


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off