1. I've been having some difficulties getting my frames to move. I was able to solve this issue with my last addon (WoWPedometer) but even with the same code added to my new addon I cannot get it moving. What am I doing wrong...

    The relevant code can be found here.

    Thanks,

    -z

  2. As I know, this line already makes ur window movable :

    <Frame name="WoWPUGBuilderFrame" toplevel="true" parent="UIParent" enableMouse="true" moveable="true" frameStrata="LOW">

    U don't need to write extra code...

  3. So, is the following unnecessary then?

            <OnDragStart>
                self:StartMoving()
            </OnDragStart>
            <OnDragStop>
                self:StopMovingOrSizing()
            </OnDragStop>
    

    and what about the .lua code?

     function WoWPUGBuilder_OnLoad(frame)
        frame:RegisterForDrag("LeftButton")
     end
    
  4. Making it movable is just a matter of enabling the movable flag. You need to set the script handlers. Troubleshooting:

    1. Check your Logs\FrameXML.log file to see if there are any errors.
    2. Alternatively, validate your file against the schema.
    3. Add a print statement to the load function to ensure it's being called.
    4. Add a print statement to the ondragstart function to ensure it's being called.
    5. Add a print statement to the ondragstop function to ensure it's being called.

    Report back.

  5. Maybe I've made a mistake about extra code) try this in .xml. Without any functions in .lua

     <OnLoad>
          this:RegisterForDrag("LeftButton");
     </OnLoad>
     <OnDragStart>
          if(arg1 == "LeftButton") then
            this:StartMoving();
          end
     </OnDragStart>
     <OnDragStop>
          this:StopMovingOrSizing();
     </OnDragStop>
    
  6. Maybe I've made a mistake about extra code) try this in .xml. Without any functions in .lua

     <OnLoad>
          this:RegisterForDrag("LeftButton");
     </OnLoad>
     <OnDragStart>
          if(arg1 == "LeftButton") then
              this:StartMoving();
          end
     </OnDragStart>
     <OnDragStop>
          this:StopMovingOrSizing();
     </OnDragStop>
    

    You should be using self:RegisterForDrag("LeftButton"), although that might not be it. Actually there are a few issues in your code:

      <OnLoad>
           self:RegisterForDrag("LeftButton");
      </OnLoad>
      <OnDragStart>
           if(button == "LeftButton") then
            self:StartMoving();
           end
      </OnDragStart>
      <OnDragStop>
           self:StopMovingOrSizing();
      </OnDragStop>
    
  7. From what I gather from the book, in chapter 12 it shows the following code for the combat tracker example as the only bits necessary to make a frame movable...

    in the XML file...

    add "movable="true"" attribute to

      <Button>
    

    add

      <OnDragStart>
        self:StartMoving()
      </OnDragStart>
      <OnDragStop>
        self:StopMovingOrSizing()
      </OnDragStop>
    

    and in the Lua file...

    add to the OnLoad function...

      frame:RegisterForDrag("LeftButton")
    

    This code works fine for combat tracker. I've used the same code for my first addon WoWPedometer, though I remember it not working at first. I've used the same code for this new addon and it doesn't want to work.

    I've gone and added

      ChatFrame1:AddMessage("OnDragStart");
    

    and

      ChatFrame1:AddMessage("OnDragStop"); 
    

    to the appropriate scripts... when I try to drag the frame I only get the "OnDragStop" message. It seems that self:StartMoving() is not being called.

    The only difference I can see between my usage of this code in this addon and my previous one is that in my previous addon the frame was <Button> rather then <Frame>.

    Could you try and run the code for my addon given in the link and let me know what you think might be getting screwed up?

    Thanks, -z

  8. If u want to make a frame draggable why do u add an attribute to a button?

  9. The problem is your OnLoad function is never being called. You should always add a simple "print" statement when debugging to check if that's the case.

     <OnLoad function="WoWPUGBuilderFrame_OnLoad"/>
    

    should be

     <OnLoad function="WoWPUGBuilder_OnLoad"/>
    
  10. If u want to make a frame draggable why do u add an attribute to a button?

    That's not what he's doing. He said in the previous addon he was writing it was a button, and now he's trying to do the same thing to a frame and it's not working. He's completely right in that the code appears to be the same.. but there was a subtle error that was causing his code not to run.

  11. Okay I got it. I not only fixed the OnLoad typo but also it appears that I spelled "movable" incorrectly. So as a result, I just took some time to drill into my skull the importance of using XML nanny. ;)

    All is well now.

    Thank you for the awesome assistance.

    -z

  12. Np, glad it worked out for you!