Thread Tools Display Modes
02-18-10, 09:01 AM   #1
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Align frame to cursor

Hi all!

How do I align a frame relative to the cursor? For game tooltips you can use :SetOwner(nil, "ANCHOR_CURSOR"), but can this also be done for regular frames? This is what I have so far(just some sample code), but it doesn't seem the best solution(rather inefficient):

lua Code:
  1. local f = CreateFrame("Frame")
  2. f:SetSize(10,10)
  3. f.tex = f:CreateTexture()
  4. f.tex:SetAllPoints(f)
  5. f.tex:SetTexture(0, 0, 0)
  6. f:SetScript("OnUpdate", function(self)
  7.     local x, y = GetCursorPosition()
  8.     local scale = UIParent:GetEffectiveScale()
  9.     x, y = x/scale, y/scale
  10.     self:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x, y)
  11. end)
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-18-10, 01:04 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
That's the only way to do it.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
02-18-10, 01:09 PM   #3
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Thanks for the confirmation.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-18-10, 02:05 PM   #4
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Ok, this is what it was for: http://www.wowinterface.com/download...HoverName.html
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Align frame to cursor


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