View Single Post
04-14-12, 02:25 PM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Example:
http://imgur.com/a/39TYH#0

There is a small button with the text "A" on it. Clicking the button will toggle the achievment frame.

Button will be less visibile by default and fade in on mouseover.

The red color comes from using a Blizzard button template called "UIPanelButtonTemplate"

Code to do it:
Lua Code:
  1. local myButton = CreateFrame("Button", "myFirstButton", UIParent, 'UIPanelButtonTemplate')
  2.   myButton:SetSize(20,20)
  3.   myButton:SetPoint("CENTER",200,0)
  4.   myButton:SetText('A')
  5.   myButton:RegisterForClicks("LeftButtonUp")
  6.   myButton:SetScript("OnClick", function() ToggleAchievementFrame() end)
  7.   myButton:SetAlpha(0.2)
  8.   myButton:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
  9.   myButton:SetScript("OnLeave", function(self) self:SetAlpha(0.2) end)

http://wowprogramming.com/docs/api/CreateFrame
http://wowprogramming.com/docs/api/SetPoint
http://wowprogramming.com/docs/api/SetSize

etc.

How to create the addon for it.

Go to your WoW AddOns folder. Create a folder "myFirstButton". In that folder create a file called "myFirstButton.toc".

Put this code into the file
Lua Code:
  1. ## Interface: 40300
  2. ## Author: You
  3. ## Title: myFirstButton
  4. ## Notes: Buttons
  5.  
  6. core.lua

Now create another file called "core.lua" and copy the button code from above in that file.

Restart WoW to load the addon.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-14-12 at 02:30 PM.