Thread Tools Display Modes
05-21-09, 06:37 AM   #1
Samsan
An Aku'mai Servant
 
Samsan's Avatar
Join Date: May 2009
Posts: 33
Question Swapping Bg images with a xml button.

Hey, I'm trying to us a normal button in xml to swap an image in a frame. It just doesn't do anything OnClick. Any ideas please?

snippets:

XML Options Panel
Code:
         <Button name="AquaBgButton" toplevel="true" enableMouse="true" text="Aqua Skin">
            <Size>
              <AbsDimension x="130" y="35" />
            </Size>
            <Anchors>
              <Anchor point="TOPLEFT">
                <Offset>
                  <AbsDimension x="19" y="-55" />
                </Offset>
              </Anchor>
            </Anchors>
            <Scripts>
              <OnLoad>
                self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
              </OnLoad>
              <OnClick>
                DWMPackBaseFrame_OnClick(self);
              </OnClick>
            </Scripts>
            <NormalTexture file="interface\glues\common\glue-panel-button-up-blue">
              <TexCoords left="0" right="0.625" top="0" bottom="0.6875" />
            </NormalTexture>
            <PushedTexture file="interface\glues\common\glue-panel-button-down-blue">
              <TexCoords left="0" right="0.625" top="0" bottom="0.6875" />
            </PushedTexture>
            <DisabledTexture file="Interface\Buttons\UI-Panel-Button-Disabled">
              <TexCoords left="0" right="0.625" top="0" bottom="0.6875" />
            </DisabledTexture>
            <HighlightTexture file="interface\glues\common\glue-panel-button-highlight-blue" alphaMode="ADD">
              <TexCoords left="0" right="0.625" top="0" bottom="0.6875" />
            </HighlightTexture>
            <ButtonText name="$parentText">
              <FontHeight>
                <AbsValue val="10" />
              </FontHeight>
            </ButtonText>
            <NormalFont style="GameFontNormal" />
            <HighlightFont style="GameFontHighlight" />
            <DisabledFont style="GameFontDisable" />
            <PushedTextOffset x="0" y="0" />
          </Button>
Lua Base

Code:
local textureName, DWMBgTexture1, DWMBgTexture2, DWMBgTexture3, DWMBgTexture4, DWMBgTexture5, DWMBgTexture6;

function DWMPackBaseFrame_OnClick(self)

    if ( AquaBgButton == "LeftButton" ) then
        DWMBgTexture1:SetTexture(Texture1, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S1");
        DWMBgTexture2:SetTexture(Texture2, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S2");
        DWMBgTexture3:SetTexture(Texture3, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S3");
        DWMBgTexture4:SetTexture(Texture4, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S4");
        DWMBgTexture5:SetTexture(Texture5, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S5");
        DWMBgTexture6:SetTexture(Texture6, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S6");
    end
end
Xml BaseFrame

Code:
     <Frame name="DWMBgTexture2" id="2">
        <Size>
          <AbsDimension x="256" y="256" />
        </Size>
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset>
              <AbsDimension x="256" y="0" />
            </Offset>
          </Anchor>
        </Anchors>
        <Layers>
          <Layer>
            <Texture name="$parentTexture2" setAllPoints="true" file="interface\AddOns\DWMPack\Backs\DWM-Base-Bg-TopMid">
              <TexCoords left="0" right="1" top="0" bottom="1" />
            </Texture>
          </Layer>
        </Layers>
      </Frame>
__________________
To give is to receive so the more that you give the more that you receive.

Last edited by Samsan : 05-21-09 at 06:41 AM. Reason: forgot frame
  Reply With Quote
05-21-09, 07:25 AM   #2
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
I stopped working with XML a while ago so I'm a bit rusty. I believe your problem is that you're not making the correct references.

Code:
    if ( AquaBgButton == "LeftButton" ) then
        DWMBgTexture1:SetTexture(Texture1, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S1");
        DWMBgTexture2:SetTexture(Texture2, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S2");
        DWMBgTexture3:SetTexture(Texture3, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S3");
        DWMBgTexture4:SetTexture(Texture4, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S4");
        DWMBgTexture5:SetTexture(Texture5, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S5");
        DWMBgTexture6:SetTexture(Texture6, "Interface\\AddOns\\DWMPack\\Skins\\Aqua-Panel_S6");
    end
Try changing this to

Code:
DWMBgTexture1Texture1:("blah blah blah")
Your texture name is actually "DWMBgTexture1Texture1" as $parent automatically adds the parent's name in from of whatever name you select.

Hope that makes sense. I just woke up and head not unfoggy yet.
  Reply With Quote
05-21-09, 08:08 AM   #3
Samsan
An Aku'mai Servant
 
Samsan's Avatar
Join Date: May 2009
Posts: 33
Smile Yay!

Thx so much...I was attempting to run it in the lua not the xml and once I out it in the xml it worked fine....

I feel like a noob in the deep end...lol... That was bugging me for weeks and there's not a lot out there answers wise that I could find.
__________________
To give is to receive so the more that you give the more that you receive.

Last edited by Samsan : 05-21-09 at 08:49 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Swapping Bg images with a xml button.


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