Thread Tools Display Modes
05-09-11, 04:13 PM   #1
Be3f.
A Theradrim Guardian
 
Be3f.'s Avatar
Join Date: Jan 2011
Posts: 65
Change color on click (kgPanels)

Hi guys, here's the deal.

What I'm currently looking for is a way for a panel to change color when clicked, and switch back to the "normal" color when clicked again.
With my knowledge in lua nearly being non existing, I have no clue on how to do this, expect I guess it's in the "onclick" section.
I've tried searching the forum among others without any luck. Help will be much appreciated.
__________________
-- Be3f.
  Reply With Quote
05-09-11, 04:47 PM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Be3f. View Post
Hi guys, here's the deal.

What I'm currently looking for is a way for a panel to change color when clicked, and switch back to the "normal" color when clicked again.
With my knowledge in lua nearly being non existing, I have no clue on how to do this, expect I guess it's in the "onclick" section.
I've tried searching the forum among others without any luck. Help will be much appreciated.
Hmm, let's see if something like this works:

OnClick
Code:
local color1 = {1, 1, 1, 1}  -- r, g, b, alpha
local color2 = {0, 0, 0, 1}

if pressed then
  if not self.mytag then
    self.bg:SetVertexColor(unpack(color2))
    self.mytag = true
  else
    self.bg:SetVertexColor(unpack(color1))
    self.mytag = false
  end
end
  Reply With Quote
05-09-11, 04:57 PM   #3
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
Hmm, let's see if something like this works:

OnClick
Code:
local color1 = {1, 1, 1, 1}  -- r, g, b, alpha
local color2 = {0, 0, 0, 1}

if pressed then
  if not self.mytag then
    self.bg:SetVertexColor(unpack(color2))
    self.mytag = true
  else
    self.bg:SetVertexColor(unpack(color1))
    self.mytag = false
  end
end
Yep, it works
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
05-10-11, 01:25 AM   #4
Be3f.
A Theradrim Guardian
 
Be3f.'s Avatar
Join Date: Jan 2011
Posts: 65
Originally Posted by Nibelheim View Post
Hmm, let's see if something like this works:

OnClick
Code:
local color1 = {1, 1, 1, 1}  -- r, g, b, alpha
local color2 = {0, 0, 0, 1}

if pressed then
  if not self.mytag then
    self.bg:SetVertexColor(unpack(color2))
    self.mytag = true
  else
    self.bg:SetVertexColor(unpack(color1))
    self.mytag = false
  end
end
Lovely! thank you very much, and to Lily too <3
__________________
-- Be3f.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Change color on click (kgPanels)


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