Thread Tools Display Modes
12-14-13, 07:25 AM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Issue with altering frame point

Hi everyone,

I have an issue where if I use this to mvoe a frames position:

Lua Code:
  1. local point, relativeFrame, relativePoint, ofsx, ofsy = mui_double:GetPoint()  
  2. mui_double:SetPoint(value, relativeFrame, relativePoint, ofsx, ofsy)

then when I run it a second time without reloading the UI then it has no effect on the frame.

Has anyone else encountered this issue before and know a fix for it? I did not know you cannot alter a frames point only once and a reload is needed to fix it as that is the issue.
  Reply With Quote
12-14-13, 07:36 AM   #2
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Please include more code. To start with, the code that defines the value variable.
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
12-14-13, 07:44 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Without seeing the rest of your code -- come on, you've been around here long enough to know better -- I can only guess that your SetPoint call is failing because you aren't calling ClearAllPoints first.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-14-13, 07:49 AM   #4
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Malsomnus View Post
Please include more code. To start with, the code that defines the value variable.
Ok, sure. I think this is the only relevant code however I will upload the file anyway if that helps:


Lua Code:
  1. Panels = { -- This is from the MayronUI.db.profile table
  2.     UnitFrameBG = {
  3.         Width = 752,
  4.         Height = 180,
  5.         ofsx = '0',
  6.         ofsy = '-110',
  7.         point = 'BOTTOM',
  8.         relativeFrame = 'mui_actionBars',
  9.         relativePoint = "TOP",
  10.         frameStrata = 'BACKGROUND',
  11.         frameLevel = 5,
  12.     },
  13.  
  14.  
  15. local p = MayronUI.db.profile.Panels
  16. mui_single = CreateFrame("Frame", "mui_single", mui_menuBar)
  17. mui_single:SetPoint(p.UnitFrameBG.point, p.UnitFrameBG.relativeFrame, p.UnitFrameBG.relativePoint, p.UnitFrameBG.ofsx, p.UnitFrameBG.ofsy)
  18. -- There are more methods being used for this object but did not include them
  19.  
  20. point = { -- This option is for altering the frames point in a drop down list
  21.     order = 5,
  22.     type = "select",
  23.     name = "Frame Point",
  24.     get = function()
  25.         return MayronUI.db.profile.Panels.UnitFrameBG.point
  26.     end,
  27.     set = function(info, value)
  28.         MayronUI.db.profile.Panels.UnitFrameBG.point = value
  29.         local point, relativeFrame, relativePoint, ofsx, ofsy = mui_single:GetPoint()
  30.             mui_single:SetPoint(value, relativeFrame, relativePoint, ofsx, ofsy)
  31.  
  32.         local point, relativeFrame, relativePoint, ofsx, ofsy = mui_double:GetPoint()  
  33.             mui_double:SetPoint(value, relativeFrame, relativePoint, ofsx, ofsy)
  34.     end,
  35.     values = {
  36.         TOP = "Top",
  37.         TOPLEFT = "Top Left",
  38.         TOPRIGHT = "Top Right",
  39.         BOTTOM = "Bottom",
  40.         BOTTOMLEFT = "Bottom Left",
  41.         BOTTOMRIGHT = "Bottom Right",
  42.         LEFT = "Left",
  43.         RIGHT = "Right",
  44.         CENTER = "Center",
  45.     },
  46.     style = "dropdown",
  47. },

Last edited by Mayron : 12-14-13 at 07:55 AM.
  Reply With Quote
12-14-13, 07:50 AM   #5
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Phanx View Post
Without seeing the rest of your code -- come on, you've been around here long enough to know better -- I can only guess that your SetPoint call is failing because you aren't calling ClearAllPoints first.
I thought it would be more simple hehe, sorry. And ok I will look into that
  Reply With Quote
12-14-13, 08:00 AM   #6
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Yet another simple error. Phanx is right its because I am not using ClearAllPoints() first. I thought it was a very simple error which is why I did not post much code before but sorry about that

Thank you!
  Reply With Quote
12-14-13, 01:57 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
To clarify, a frame can have more than one anchor. If you don't call :ClearAllPoints(), you're just adding an additional anchor to your frame.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-14-13, 03:09 PM   #8
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by Seerah View Post
To clarify, a frame can have more than one anchor. If you don't call :ClearAllPoints(), you're just adding an additional anchor to your frame.
Wait, but you CAN use code like the original poster's for moving an existing anchor point, right...?
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
12-14-13, 03:29 PM   #9
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Seerah View Post
To clarify, a frame can have more than one anchor. If you don't call :ClearAllPoints(), you're just adding an additional anchor to your frame.
Don't worry I do know this. I dont actually want to remove all, I just wanted to redo one of the anchors with new values but if I alter "BOTTOM" point for example then I cannot alter it a second time which I thought was odd. Its just for selecting a new anchor point with a drop down menu.
  Reply With Quote
12-14-13, 04:09 PM   #10
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You can reset the same pointing without clearing, yes. Your code, though, as far as I understand, should not be expected to do anything in this case.
Code:
local point, relativeFrame, relativePoint, ofsx, ofsy = mui_double:GetPoint()  
            mui_double:SetPoint(value, relativeFrame, relativePoint, ofsx, ofsy)
You take the point value from the dropdown selection, and the rest from the existing point. If the dropdown selection equals the existing point, that means all the arguments passed to SetPoint as the same as the returns from GetPoint, and you're setting the exact same point again.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
12-14-13, 07:19 PM   #11
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Lombra View Post
You can reset the same pointing without clearing, yes. Your code, though, as far as I understand, should not be expected to do anything in this case.
Code:
local point, relativeFrame, relativePoint, ofsx, ofsy = mui_double:GetPoint()  
            mui_double:SetPoint(value, relativeFrame, relativePoint, ofsx, ofsy)
You take the point value from the dropdown selection, and the rest from the existing point. If the dropdown selection equals the existing point, that means all the arguments passed to SetPoint as the same as the returns from GetPoint, and you're setting the exact same point again.
That is what I assumed as well but it just would not work which makes no sense to me. I will retry but for some reason when I do this method, the second time I do it, nothing changes.
  Reply With Quote
12-14-13, 09:33 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you set, for example "BOTTOMRIGHT to the CENTER of the UIParent" and then "BOTTOM to the CENTER of the UIParent", technically you have set both of those points, and you should be able to retrieve them via GetPoints(1) and GetPoints (2), but practically you won't see a differerence, because how can two different parts of your frame both be exactly in the center of the UIParent? That's why you need to use ClearAllPoints.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-15-13, 06:33 AM   #13
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Phanx View Post
If you set, for example "BOTTOMRIGHT to the CENTER of the UIParent" and then "BOTTOM to the CENTER of the UIParent", technically you have set both of those points, and you should be able to retrieve them via GetPoints(1) and GetPoints (2), but practically you won't see a differerence, because how can two different parts of your frame both be exactly in the center of the UIParent? That's why you need to use ClearAllPoints.
Yes thats true. I fixed the issue in the end just by altering how the setting worked in other ways and controlled the points better while taking into consideration all the tips I was given so thank you and everyone else
  Reply With Quote
12-15-13, 07:14 AM   #14
pelf
Sentient Plasmoid
 
pelf's Avatar
Premium Member
Join Date: May 2008
Posts: 133
Originally Posted by Phanx View Post
[...] because how can two different parts of your frame both be exactly in the center of the UIParent?
The client should be folding the frame's bottom middle and bottom right together and then attaching that to UIParent's center.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issue with altering frame 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