Thread Tools Display Modes
05-18-10, 08:01 AM   #1
PerfectH
A Flamescale Wyrmkin
 
PerfectH's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2008
Posts: 137
kgPanels - Custom Buttons (OnClick)

Good morning, WoWInterface community and Happy Tuesday to you all!

Okay, down to business: I am once again trying to make this script work for kgPanels to spice up my UI a little before I republish it with an update. My goal is to have a button (actually, there will be two identical buttons that will perform the same actions) that upon clicking it will show a different image - to be more precise: it will be a similar image of the button but with the "pressed" effect applied. After releasing the mouse button, I want the original image to return.

(Idle) TalentButton1.tga -> (Pressed) TalentButton2.tga -> (Released) TalentButton1.tga

So that is one half of what I am trying to accomplish. The other half - which actually maybe easier - is to have the Talent Pane toggle on/off upon releasing the mouse button when clicking these custom buttons.

(Idle) TalentButton1.tga -> (Pressed) TalentButton2.tga -> (Released) TalentButton1.tga (Talent Pane Appears)
(Idle) TalentButton1.tga -> (Pressed) TalentButton2.tga -> (Released) TalentButton1.tga (Talent Pane Hides)

I'm almost certain these are doable...however, I am still learning Lua and I am not well equipped enough with the knowledge of how to perform such actions. Any help would be greatly appreciated - I'll paypal you money for a Coke*!

Thanks in advance,
PerfectH
"Coke Man"

*Donations for aiding said forum member is strictly for buying a Coke or any Coca-Cola owned product. Buying a none Coca-Cola owned product will disqualify you immediately from receiving further donations from said forum member as well as being ridiculed. Please choose wisely
__________________
I might fail at AddOn creativity...but damn do I love Coca-Cola!
  Reply With Quote
06-06-10, 10:28 AM   #2
PerfectH
A Flamescale Wyrmkin
 
PerfectH's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2008
Posts: 137
Still need help :O
__________________
I might fail at AddOn creativity...but damn do I love Coca-Cola!
  Reply With Quote
06-06-10, 03:35 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Here it states how to do something on press and release: http://www.wowace.com/addons/kg-panels/

I haven't tried to change backgrounds of a panel before in a script. I think most people use two panels and hide/show the frames depending on what they want seen... One way you could do it is place your second texture in a kgPanel directly behind the first. When you press the first, set its alpha to 0 (so you can see the second) - when you release, set the alpha back to 1 and show/hide the talent frame.
__________________
"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

  Reply With Quote
06-06-10, 03:42 PM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
You'd use these button methods for the textures:

SetNormalTexture
SetPushedTexture

For the other, you'd use the OnMouseUp script by way of the button/frame's SetScript method.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
06-06-10, 04:02 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
psst... Torhal... kgPanels are just frames, not buttons.
__________________
"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

  Reply With Quote
06-06-10, 07:56 PM   #6
Gylindor
A Defias Bandit
Join Date: Apr 2009
Posts: 3
TalentButton1:SetScript("OnMouseDown", function(_,button)
if button=="LeftButton" then TalentButton2.tga(Show) end
end)

TalentButton2:SetScript("OnMouseUp", function(_,button)
if button=="LeftButton" then ToggleTalentFrame() and TalentButton2.tga(Hide) end
end)

As an idea, the second script runs on Button2 as I'm guessing this will be drawn over Button 1 in use
  Reply With Quote
06-06-10, 09:15 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
no no, you don't need to do that stuff with kgPanels.


PerfectH... make your two kgPanels with your textures and overlay them on top of one another. Make sure that the first texture is set to have a higher draw layer than the second so that it's on top. Also, have the first panel set to "intercept mouse clicks".

Let's say you named your two panels TalentBtn and TalentBtnPushed. All you'll have to mess with, though, in the scripts section is the first - TalentBtn.

Open up the scripts section for TalentBtn and go to the OnClick section. Put this there:
Code:
if pressed then
     self:SetAlpha(0)
elseif released then
     self:SetAlpha(1)
     ToggleTalentFrame()
end
__________________
"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

  Reply With Quote
06-06-10, 11:00 PM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Seerah View Post
psst... Torhal... kgPanels are just frames, not buttons.
I know, but he clearly said he wanted buttons.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
06-07-10, 12:13 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Torhal View Post
I know, but he clearly said he wanted buttons.



(10 chars)
__________________
"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

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » kgPanels - Custom Buttons (OnClick)


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