• 0

    posted a message on Taint and you - eh?
    I reported this bug after each beta build, but they still didn't fix it, and I was forced to implement my own dropdown :(. Also, InterfaceOptions is buggy too, if you call InterfaceOptions_AddCategory(panel), and then open interface options, uncheckImage will become tainted.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Track a frames location while dragging how?
    I never write more than 1 statement on a line, but when I see a statement without semiclon in my code, first two things i think are: 1) this statement takes more than 1 line 2) otherwise, probably I forgot to finish writing this statement. I don't say that they are necessary to make code readable, but I prefer to use them, and I don't impose my opinion on anyone. Lets stop offtopic about it...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Track a frames location while dragging how?
    Quote from Galvin
    It works just not sure how to put that into my code. My code only activates the onupdate during drag only then setscript nil on the drop. That way it's not running all the time. Right now I have full drag and drop and swap working. I'll have to study it some more.

    http://www.pastey.net/140444-q3l6
    This version uses OnSizeChanged (take a look on the last comment).
    Quote from Torhal
    You can get rid of a couple of anonymous functions

    Yes, thank you, your code is a bit better :)
    Quote from Torhal
    The semi-colons are completely unnecessary as well - they mainly exist so the Lua code doesn't throw errors on people used to working with C-like languages where they're a necessity.

    They are unnecessary, but they can improve readability in some cases (imho). Anyway, I'm too used to them.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Track a frames location while dragging how?
    Quote from Galvin
    If you can give me an example of using OnSizeChanged. Only thing is i'm not changing size though.

    	
    -- frame whose position we are tracking
    local MyFrame1 = CreateFrame("Frame", nil, UIParent);
    MyFrame1:SetHeight(100);
    MyFrame1:SetWidth(100);
    MyFrame1:SetPoint("CENTER");
    local Texture1 = MyFrame1:CreateTexture();
    Texture1:SetAllPoints();
    Texture1:SetTexture(0, 0, 0);
    	
    MyFrame1:EnableMouse(true);
    MyFrame1:SetMovable(true);
    MyFrame1:SetScript("OnMouseDown", function(self, button)
    	self:StartMoving();
    end);
    MyFrame1:SetScript("OnMouseUp", function(self, button)
    	self:StopMovingOrSizing();
    end);
    
    -- additional frame, whose width equals to MyFrame1's x coordinate, height = y coordinate
    MyFrame2 = CreateFrame("Frame", nil, MyFrame1);
    MyFrame2:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT");
    MyFrame2:SetPoint("TOPRIGHT", MyFrame1, "TOPLEFT");
    MyFrame2:SetScript("OnSizeChanged", function(self, width, height)
    	print("x: " .. width .. " y: " .. height);
    	print("GetLeft: " .. MyFrame1:GetLeft() .. " GetTop: " .. MyFrame1:GetTop());
    end);
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Track a frames location while dragging how?
    Instead of using OnUpdate script you can create an additional frame, set its BOTTOMLEFT to UIParent's BOTTOMLEFT, TOPRIGHT to TOPLEFT of tracked frame, and use new frame's OnSizeChanged(self, width, height) script. The benefits of this approach are 1) this script is being called only when position is changed, not every frame between mouse down and mouse up 2) you don't need to call :GetLeft() and :GetTop() to recognize new frame position.
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    You should set frame movable before interface loaded, otherwise position will not be restored. Also, check, if frame created before interface loading process is completed. And check if your addon rewrites frame position after interface loaded.
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    Quote from melchior5387
    yes all frames have names, but do I need to name a savedvariables file with that ? Where does the information will be saved ?

    You don't need to store frame position in savedvariables, WoW saves it in "WTF\Account\AccountName\Server\CharacterName\layout-local.txt".

    Quote from melchior5387
    I keep the line "## SavedVariables: MyAddonSaves" in the .toc file and I use

    Frame:SetUserPlaced(true) ? Is it all ?

    If you need "MyAddonSaves" for something besides frame position, then yes. If you store in "MyAddonSaves" frame positions only, then you can delete this line.
    Posted in: Lua Code Discussion
  • 0

    posted a message on how to save frame position correctly
    If these frames have names, you can call Frame:SetUserPlaced(true) method, that tells frame to save position and sizes before logging out/interface reloading, and restore them when interface starts up.
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.