Thread Tools Display Modes
04-11-12, 09:04 PM   #1
Artanis186
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 18
Custom Clickable Buttons

So I'm designing my interface with a very specific idea in mind. But I need some custom buttons to make this work. What I need is a semi-transparent clickable button that can have an image set as it (bonus points for 'hover' and 'click' states) with custom X and Y dimensions and can be set to do things like open the Friends list, open the achievements, open the menu, etc. I need it to be movable and have at least 5 different buttons at a time that each have a different image and ability.

EDIT: Simply put I want to be able to add an image to my UI of any dimension that you can click to open various panels.

If all of this is possible and could be provided in a single addon, I would greatly appreciate it being linked. Else if it'd be simple enough for a competent individual (that hasn't actually designed any UI items for WoW before) to make, it'd be nice to get an idea how to do that.

Last edited by Artanis186 : 04-11-12 at 09:09 PM.
 
04-11-12, 09:31 PM   #2
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Take a look at CustomButtons, or maybe Button Forge for the "buttons".

You can make your own custom graphics to use (as long as you save them to the proper size and image format) and put them in a folder (titled ICONS) in your Interface folder and they will show up in the icons for the Macro window.

Which leads me to this: I know there are scripts, or macros, you can run to open just about any default window in WoW. I don't know them, unfortunately, but I've seen them posted a few times on boards and know they're available.

EDIT: Or, you might take a look at nibMicroMenu /EDIT
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 04-11-12 at 09:35 PM.
 
04-11-12, 09:46 PM   #3
Artanis186
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 18
None of those seem to do what I need. I need custom graphics with specifically sized rectangular buttons and no forced borders.
 
04-12-12, 01:45 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I made myself a button for vehicle exit.
Lua Code:
  1. local b = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate");
  2.   b:SetSize(50,50)
  3.   b:SetPoint("CENTER",0,0)
  4.   b:RegisterForClicks("AnyUp")
  5.   b:SetNormalTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
  6.   b:SetPushedTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  7.   b:SetHighlightTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  8.   b:SetScript("OnClick", function(self) VehicleExit() end)
  9.   RegisterStateDriver(b, "visibility", "[target=vehicle,exists] show;hide")
Nearly the same could be done for anything else. You may even add a new texture to the button to display any type of icon. Spell textures can be get via GetSpellInfo(). If you want no highlight/border textures just leave them out. As you can see you can even add macro-states for visibility.

Adding a texture could be done like this (Only needed if you want to add a border-texture as normaltexture. Otherwise just use normaltexture for this)
Lua Code:
  1. --icon texture
  2.     local _, _, icon_texture = GetSpellInfo(spellid) --input your spellid here
  3.     local t = b:CreateTexture(nil,"BACKGROUND",nil,-6)
  4.     t:SetTexture(icon_texture)
  5.     t:SetTexCoord(0.1,0.9,0.1,0.9) --cut out crappy icon border
  6.     t:SetAllPoints(b) --make texture same size as button

If you want hover-states with different alpha you need to add OnEnter and OnLeave events with the behaviour you want to achieve. Like
Lua Code:
  1. --alpha
  2.     b:SetAlpha(0.2)
  3.     b:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
  4.     b:SetScript("OnLeave", function(self) self:SetAlpha(0.2) end)

Just write your own addon for this.
__________________
| 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-12-12 at 02:05 AM.
 
04-14-12, 09:40 AM   #5
Artanis186
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 18
Thanks for the info, but considering my experience, I could use some help. I have no idea how to make it do something simple, like show a UI panel. Could you lead me in the right direction there?
 
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.
 
01-23-20, 09:00 AM   #7
Narfi
A Murloc Raider
Join Date: Jan 2020
Posts: 7
years aber

Originally Posted by zork View Post
I made myself a button for vehicle exit.
Lua Code:
  1. local b = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate");
  2.   b:SetSize(50,50)
  3.   b:SetPoint("CENTER",0,0)
  4.   b:RegisterForClicks("AnyUp")
  5.   b:SetNormalTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
  6.   b:SetPushedTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  7.   b:SetHighlightTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  8.   b:SetScript("OnClick", function(self) VehicleExit() end)
  9.   RegisterStateDriver(b, "visibility", "[target=vehicle,exists] show;hide")
Nearly the same could be done for anything else. You may even add a new texture to the button to display any type of icon. Spell textures can be get via GetSpellInfo(). If you want no highlight/border textures just leave them out. As you can see you can even add macro-states for visibility.

Adding a texture could be done like this (Only needed if you want to add a border-texture as normaltexture. Otherwise just use normaltexture for this)
Lua Code:
  1. --icon texture
  2.     local _, _, icon_texture = GetSpellInfo(spellid) --input your spellid here
  3.     local t = b:CreateTexture(nil,"BACKGROUND",nil,-6)
  4.     t:SetTexture(icon_texture)
  5.     t:SetTexCoord(0.1,0.9,0.1,0.9) --cut out crappy icon border
  6.     t:SetAllPoints(b) --make texture same size as button

If you want hover-states with different alpha you need to add OnEnter and OnLeave events with the behaviour you want to achieve. Like
Lua Code:
  1. --alpha
  2.     b:SetAlpha(0.2)
  3.     b:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
  4.     b:SetScript("OnLeave", function(self) self:SetAlpha(0.2) end)

Just write your own addon for this.
Just still helpful for me at classic : )

thanks Zork

Gruss
 
02-23-20, 07:04 AM   #8
hasnogaems
A Flamescale Wyrmkin
 
hasnogaems's Avatar
Join Date: Apr 2016
Posts: 109
Thank you for this guide zork, is very nice.

Originally Posted by jeffy162 View Post
Take a look at CustomButtons
This link lead to no addon, and I googled it and did not find any.

Last edited by hasnogaems : 02-23-20 at 07:21 AM.
 
02-23-20, 09:06 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by hasnogaems View Post
Thank you for this guide zork, is very nice.

This link lead to no addon, and I googled it and did not find any.
Considering that link is from almost 8 years ago, it's likely that the addon no longer exists.

I'll be locking this thread now. Anything new can be put in a new thread.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

 

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Custom Clickable Buttons

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