1. I am trying to create and position a close button as well as make the frame movable. I have the following XML code:

     <Ui xmlns="http://www.blizzard.com/wow/ui/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.blizzard.com/wow/ui/
        http://wowprogramming.com/FrameXML/UI.xsd">
       <Frame name="Wraith411" parent="UIParent">
          <Size x="530" y="345"/>
          <Anchors>
              <Anchor point="LEFT" relativePoint="LEFT" relativeTo="UIParent"/>
          </Anchors>
          <Layers>
              <Layer level="BACKGROUND">
                  <Texture name="$parent_Portrait" parentKey="portrait" file="Interface\icons\inv_misc_enggizmos_30">
                      <Size x="60" y="60"/>
                      <Anchors>
                          <Anchor point="TOPLEFT">
                              <Offset x="7" y="-6"/>
                          </Anchor>
                      </Anchors>
                  </Texture>
              </Layer>
              <Layer level="OVERLAY">
                  <FontString name="$parent_Title" parentKey="title" inherits="GameFontNormal" text="Test Mod!">
                      <Anchors>
                          <Anchor point="TOP">
                              <Offset x="-55" y="-18"/>
                          </Anchor>
                      </Anchors>
                  </FontString>
              </Layer>
              <Layer level="BORDER">
             <Texture file="Interface\TUTORIALFRAME\UI-HELP-FRAME-MAIN">
                      <Anchors>
                          <Anchor point="TOPLEFT"/>
                      </Anchors>
                  </Texture>
           </Layer>
          </Layers>
         <Frames>
           <Button name="$parent_Close" parentKey="close" inherits="UIPanelCloseButton">
             <Anchors>
               <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" relativeTo="UIParent">
                 <Offset x="-17" y="-8"/>
               </Anchor>
             </Anchors>
           </Button>
         </Frames>
          <Scripts>
              <OnLoad function="Wraith411_OnLoad"/>
          </Scripts>
       </Frame>
     </Ui>
    

    My first question pertains to the close button, more importantly the code between the Button tags above. I'm trying to anchor the button to the topright of the frame, however it is anchoring it to the topright of my screen. I initially had the following code figuring I'd have to manually add the graphic before I came across the template. My code was as follows:

             <Texture file="Interface\BUTTONS\UI-Panel-MinimizeButton-Up">
               <Anchors>
                 <Anchor point="TOPRIGHT">
                   <Offset x="-17" y="-8"/>
                 </Anchor>
               </Anchors>
             </Texture>
    

    And it was positioned fine. But now using the template, it's not quite working.

    Also, how do I utilize the MakeMovable() function? I'm looking in the book (2nd ed.) on pg 179 and it displays a full function. I've tried placing that in my .lua file right under:

     function Wraith411_OnLoad(self)
        SetPortraitToTexture(self.portrait, "Interface\\Icons\\INV_Misc_EngGizmos_30")
     end
    

    I've also tried placing it in the XML in different spots. The book doesn't really say how to call this function.

    Sorry for the long post, but I've been putting many hours into this and am becoming quite frustrated.

    Any help is appreciated. Thanks in advance.

  2. I am trying to create and position a close button as well as make the frame movable. I have the following XML code:

    My first question pertains to the close button, more importantly the code between the Button tags above. I'm trying to anchor the button to the topright of the frame, however it is anchoring it to the topright of my screen. I initially had the following code figuring I'd have to manually add the graphic before I came across the template. My code was as follows:

             <Texture file="Interface\BUTTONS\UI-Panel-MinimizeButton-Up">
               <Anchors>
                 <Anchor point="TOPRIGHT">
                   <Offset x="-17" y="-8"/>
                 </Anchor>
               </Anchors>
             </Texture>
    

    And it was positioned fine. But now using the template, it's not quite working.

    It's not the template that's the problem, it is the anchor point that you've set. Look at the relativeTo attribute, you have it set to UIParent, which is your entire UI. Set it instead to the frame you want to anchor it to, or leave it blank for it to default to the parent.

    Also, how do I utilize the MakeMovable() function? I'm looking in the book (2nd ed.) on pg 179 and it displays a full function. I've tried placing that in my .lua file right under:

     function Wraith411_OnLoad(self)
      SetPortraitToTexture(self.portrait, "Interface\\Icons\\INV_Misc_EngGizmos_30")
     end
    

    I've also tried placing it in the XML in different spots. The book doesn't really say how to call this function.

    Sorry for the long post, but I've been putting many hours into this and am becoming quite frustrated.

    What I'd do is change the name of MakeMovable to Wraith411_MakeMovable so it doesn't conflict with anything else and put the function somewhere in your .lua file (it can be before or after the OnLoad, doesn't really matter).

    Then in your OnLoad code, just call it, i.e:

    Wraith411_MakeMovable(self)

    Let me know if that doesn't work!

  3. Ah, for the close button issue, I removed the relativeTo="UIParent" attribute and it works! Thank you.

    I'm curious though, if I wanted to set it relativeTo something, what would that be? The image it would be relative to is TUTORIALFRAME\UI-HELP-FRAME-MAIN which is a texture within the UIParent frame. But apparently the UIParent frame is not correct.

    And I still can't get the MakeMovable function working. In the .lua file, I have:

     function Wraith411_OnLoad(self)
        SetPortraitToTexture(self.portrait, "Interface\\Icons\\INV_Misc_EngGizmos_30")
        Wraith411_MakeMovable(self)
     end
    
     function Wraith411_MakeMovable(frame)
        frame:SetMovable(true)
        frame:RegisterForDrag("LeftButton")
        frame:SetScript("OnDragStart", frame.StartMoving)
        frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
     end
    

    And in the .xml, I have the code above:

     <Scripts>
       <OnLoad function="Wraith411_OnLoad"/>
     </Scripts>
    

    Looking at it makes sense, but still not able to move.

    Thanks in advance.

  4. you have to enable the mouse interactivity for the frame

     frame:EnableMouse(true)
    
  5. That did it. My window now moves! Thank you.

    And if anyone knows the answer to the frame question above, as to what that relativeTo would be set to in my example, it would help in my understanding of this frames concept.

    Thanks for the help.

  6. That did it. My window now moves! Thank you.

    And if anyone knows the answer to the frame question above, as to what that relativeTo would be set to in my example, it would help in my understanding of this frames concept.

    Thanks for the help.

    The relativeTo attribute needs to be the name of a frame in the UI (that is, the name attribute of some <Frame>, <Button>, or other such UI element). If it's not given, and if your frame is inside some other <Frame> element, it'll use that frame as the relative frame.

    In your example code, relativeTo="Wraith411" and leaving out the relativeTo attribute have the same effect, since the Button's immediate parent is a frame named "Wraith411".