Thread Tools Display Modes
01-12-10, 02:47 AM   #1
Ronkkrop
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 6
SetWidth + Anchor point

Hey guys. This is my first attempt at an addon, and it's going pretty awesome except for this little hang up. I have a small movable frame that i want to grow to the right no matter where it is on the screen. Yes, obviously i'm a little bit anal lol, but i do have a button on the left that changes the size of the frame, and its annoying that it gets moved away from my mouse whenever i click it. So anyways, i was told elsewhere that the problem is my anchor point and that after StopMovingOrSizing() i need to re-anchor my frame somewhere left. Which is fine...however doing so results in some wierd bugs. It resizes, and grows just as it should when its anywhere to the left of the screen, and anywhere center, however when i move it to the right side of the screen, my backdrop no longer changes size at all. Also of note is that GetWidth() returns the correct value. Is there any reason for this, is there anything i can do? It moves around via:

Conveniently, getpoint(1) just before StopMovingOrSizing(), seems to have all the right info for anchoring TOPLEFT.
lua Code:
  1. function GoldTracker_OnMouseDown()
  2.    
  3.     GoldTracker_MainFrame:StartMoving()
  4.  
  5. end
  6.  
  7. function GoldTracker_OnMouseUp()
  8.     local gtpoint, gtrelativeTo, gtrelativePoint, gtxOfs, gtyOfs = GoldTracker_MainFrame:GetPoint(1)
  9.  
  10.     GoldTracker_MainFrame:StopMovingOrSizing()
  11.     GoldTracker_MainFrame:SetPoint(gtpoint, gtxOfs, gtyOfs)
  12.        
  13. end

Last edited by Ronkkrop : 01-12-10 at 06:27 AM.
  Reply With Quote
01-12-10, 06:25 AM   #2
Ronkkrop
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 6
I seem to have fixed the issue. Apparently :ClearAllPoints() needs to be called right before :SetPoint().

However, i do have another question. Is calling :GetPoint() just before :StopMovingOrSizing() and acceptable way to retrieve the TOPLEFT x and y offsets? Will this cause problems for me later on? ...and will it function the same system to system?
  Reply With Quote
01-12-10, 08:30 AM   #3
Hati-EK
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 20
if i remember correctly
StopMovingOrSizing() - changes the anchor point to the nearest - so it could be TOPLEFT x,y=100,200 - if you force it to center -> the icon is to far away - as maybe really moved by user


maybe a help:
http://www.wowwiki.com/API_Frame_StartMoving

Last edited by Hati-EK : 01-12-10 at 08:37 AM.
  Reply With Quote
01-12-10, 02:35 PM   #4
Ronkkrop
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 6
Originally Posted by Hati-EK View Post
if i remember correctly
StopMovingOrSizing() - changes the anchor point to the nearest - so it could be TOPLEFT x,y=100,200 - if you force it to center -> the icon is to far away - as maybe really moved by user


maybe a help:
http://www.wowwiki.com/API_Frame_StartMoving

Thank you for the advice, but i already have a good knowledge of StopMovingOrSizing(). My question is if its acceptable to get a TOPLEFT x and y offset by calling GetPoint() just before StopMovingOrSizing(). Right now, it seems to give me the correct offsets, what i'm concerned about is that it's just some wierd coincidence. So, will doing what i stated always have the same behaviour?
  Reply With Quote
01-16-10, 01:56 AM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by Ronkkrop View Post
My question is if its acceptable to get a TOPLEFT x and y offset by calling GetPoint() just before StopMovingOrSizing().
It's probably better to retrieve these values from frame:GetLeft() and frame:GetTop() after calling frame:StopMovingOrSizing(). I wouldn't trust anything frame:GetPoint() returns after a user has started moving a frame. It's also a better idea to stop movement before trying to get any coordinates from the frame.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetWidth + Anchor point


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