Thread: kgPanels Button
View Single Post
10-14-14, 07:58 AM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by MalachiDraven View Post
Hiya. I'm trying to make a button using kgPanels. I want it to open/close my bags. I also want it to show/hide a different kgPanel when I click it and also when I press the "B" key to open/close my bags.
In your button panel, use these scripts:

OnLoad
lua Code:
  1. local ToggleAllBags = ToggleAllBags -- Create a local reference to the original ToggleAllBags function before we hook it
  2. hooksecurefunc("ToggleAllBags", function() -- Hook the global ToggleAllBags to call the OnClick method of this panel
  3.     self:OnClick()
  4. end)
  5.  
  6. function self:OnClick()
  7.     ToggleAllBags() -- Call the local reference to ToggleAllBags
  8.     OtherPanel:SetShown(not OtherPanel:IsShown()) -- Change OtherPanel to the name of the other panel
  9. end

OnClick
lua Code:
  1. self:OnClick()

In your other panel, add this to the OnLoad script:
lua Code:
  1. OtherPanel = self -- Change OtherPanel to the desired name of this panel

In both OnLoad scripts, change OtherPanel to some unique name for your panel.
  Reply With Quote