Thread Tools Display Modes
11-01-16, 04:25 AM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
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.
  Reply With Quote
11-01-16, 05:41 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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()
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-01-16, 12:26 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-01-16 at 12:33 PM.
  Reply With Quote
11-01-16, 04:06 PM   #4
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi SDPhantom & Lombra

Thank you both for your help.

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

Cheers
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with button textures

Thread Tools
Display Modes

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