WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Issue with altering frame point (https://www.wowinterface.com/forums/showthread.php?t=48665)

Mayron 12-14-13 07:25 AM

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.

Malsomnus 12-14-13 07:36 AM

Please include more code. To start with, the code that defines the value variable.

Phanx 12-14-13 07:44 AM

Without seeing the rest of your code -- come on, you've been around here long enough to know better :rolleyes: -- I can only guess that your SetPoint call is failing because you aren't calling ClearAllPoints first.

Mayron 12-14-13 07:49 AM

Quote:

Originally Posted by Malsomnus (Post 288176)
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. },

Mayron 12-14-13 07:50 AM

Quote:

Originally Posted by Phanx (Post 288177)
Without seeing the rest of your code -- come on, you've been around here long enough to know better :rolleyes: -- 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 :D

Mayron 12-14-13 08:00 AM

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!

Seerah 12-14-13 01:57 PM

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.

Malsomnus 12-14-13 03:09 PM

Quote:

Originally Posted by Seerah (Post 288190)
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...?

Mayron 12-14-13 03:29 PM

Quote:

Originally Posted by Seerah (Post 288190)
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.

Lombra 12-14-13 04:09 PM

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.

Mayron 12-14-13 07:19 PM

Quote:

Originally Posted by Lombra (Post 288197)
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.

Phanx 12-14-13 09:33 PM

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.

Mayron 12-15-13 06:33 AM

Quote:

Originally Posted by Phanx (Post 288206)
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 :)

pelf 12-15-13 07:14 AM

Quote:

Originally Posted by Phanx (Post 288206)
[...] 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.


All times are GMT -6. The time now is 07:31 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI