View Single Post
08-06-13, 10:07 PM   #45
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
OnClick
Code:
if not self.clicked then
    self.clicked = true
    
    ChatFrame1:Show()
    ChatFrame2:Hide()
    ChatFrame3:Hide()
    
    self.text:SetTextColor(1, 1, 1)
    
    local tab2 = kgPanels:FetchFrame("PanelLog")
    local tab3 = kgPanels:FetchFrame("PanelTrash")
    
    local _, Class = UnitClass("player")
    local Color = RAID_CLASS_COLORS[Class]
    tab2.text:SetTextColor(Color.r,Color.g,Color.b)
    tab3.text:SetTextColor(Color.r,Color.g,Color.b)
else
    self.clicked = false
end
When you are clicking you are re-setting the colours for the other two panels but you also need to re-set their "clicked" status.

So I think OnClick
Code:
if not self.clicked then
    self.clicked = true
    
    ChatFrame1:Show()
    ChatFrame2:Hide()
    ChatFrame3:Hide()
    
    self.text:SetTextColor(1, 1, 1)
    
    local tab2 = kgPanels:FetchFrame("PanelLog")
    local tab3 = kgPanels:FetchFrame("PanelTrash")
    
    local _, Class = UnitClass("player")
    local Color = RAID_CLASS_COLORS[Class]
    tab2.text:SetTextColor(Color.r,Color.g,Color.b)
    tab2.clicked = false
    tab3.text:SetTextColor(Color.r,Color.g,Color.b)
    tab3.clicked = false
else
    self.clicked = false
end
While it shouldn't be needed you could also:
OnLeave
Code:
if not self.clicked then
    local _, Class = UnitClass("player")
    local Color = RAID_CLASS_COLORS[Class]
    self.text:SetTextColor(Color.r,Color.g,Color.b)
else
    self.text:SetTextColor(1,1,1)
end
You might want to define things differently as here, once "unclicked" the button doesn't change from white to class colour until OnLeave.

The code here allows all buttons to be "unclicked" at the same time. If you want one button to always be "hot" you can remove the

else
self.clicked = false
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-06-13 at 10:19 PM.
  Reply With Quote