Originally Posted by MalachiDraven
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:
local ToggleAllBags = ToggleAllBags -- Create a local reference to the original ToggleAllBags function before we hook it
hooksecurefunc("ToggleAllBags", function() -- Hook the global ToggleAllBags to call the OnClick method of this panel
self:OnClick()
end)
function self:OnClick()
ToggleAllBags() -- Call the local reference to ToggleAllBags
OtherPanel:SetShown(not OtherPanel:IsShown()) -- Change OtherPanel to the name of the other panel
end
OnClick
In your other panel, add this to the OnLoad script:
lua Code:
OtherPanel = self -- Change OtherPanel to the desired name of this panel
In both OnLoad scripts, change
OtherPanel to some unique name for your panel.