WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help with button textures (https://www.wowinterface.com/forums/showthread.php?t=54773)

Walkerbo 11-01-16 04:25 AM

Help with button textures
 
Hi all

I have an issue with the textures on a button.
Both the highlight and pushed textures fit the button frame without issue, but the normal texture always displays much bigger than the other two thus exceeding the button size.

This is an image of what I am seeing.
http://i.imgur.com/xLcC1uS.png?1

Here is my code.

Code:

local myTestingFrame = CreateFrame("Button","myTestingFrame",UIParent, "SecureActionButtonTemplate,ActionButtonTemplate")
myTestingFrame:SetScale(2)
myTestingFrame:SetPoint("CENTER")

myTestingFrame:SetPushedTexture("Interface\\Icons\\Inv_misc_archaeology_amburfly")
myTestingFrame:SetHighlightTexture("Interface\\Icons\\Spell_shadow_carrionswarm")
myTestingFrame:SetNormalTexture("Interface\\Icons\\Spell_druid_swarm")

myTestingFrame:SetMovable(true)
myTestingFrame:SetClampedToScreen(true)
myTestingFrame:RegisterForDrag("RightButton")
myTestingFrame:SetScript("OnDragStart",myTestingFrame.StartMoving)
myTestingFrame:SetScript("OnDragStop",myTestingFrame.StopMovingOrSizing)
myTestingFrame:SetToplevel(true)
myTestingFrame:SetScript("OnClick",function(self)
print("Button Clicked")
end)

Any help would be great.

Lombra 11-01-16 05:41 AM

ActionButtonTemplate sets some anchors for the normal textures. You could try undoing them, but I'm not sure that it will be enough:
Code:

myTestingFrame:GetNormalTexture():ClearAllPoints()

SDPhantom 11-01-16 12:26 PM

The size won't reset unless you re-define the points. You could just do myTestingFrame:GetNormalTexture():SetAllPoints(myTestingFrame). Furthermore, you're inheriting templates, yet not using any of their assets. SecureActionButtonTemplate allows you to define attributes on the frame to direct its own OnClick handler to perform protected actions. Replacing this with your own code completely nullifies this. ActionButtonTemplate adds many additional frames, textures, and fontstrings to the button that aren't in use and are taking up resources just sitting there, doing nothing.

Simply removing ActionButtonTemplate from the inheritance list will fix your normal texture problem anyway. You will need to set the button size yourself.

Walkerbo 11-01-16 04:06 PM

Hi SDPhantom & Lombra

Thank you both for your help.

I ended up removing the "SecureActionButtonTemplate,ActionButtonTemplate" and now everything is working properly.

Cheers


All times are GMT -6. The time now is 11:26 PM.

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