View Single Post
11-23-14, 10:00 PM   #1
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
Simple How to Hide and Show Window Help?

I'm simply trying to understand how to show and hide a from with a right mouse click. Here is the code where I think I don't have it correct. I'm remembering how I did this with Elder Scrolls Online so I was trying it this way and mixed it with a way to do it in wow that I've found online. However it's not working.

The Code for Hidding and showing the frame with right mouse click to my button.

Lua Code:
  1. local frame = CreateFrame("Button", ZBarOptionFrame, UIParent)
  2.  
  3. ZBarOptionFrame:RegisterForClicks("AnyUp")
  4. ZBarOptionFrame:SetScrpit("OnClick", function(self, button, ...)
  5.     if (button == "RightButton") then
  6.         if ZBarOptionFrame:IsShown() then
  7.             ZBarOptionFrame:SetHidden(false)
  8.         else
  9.             ZBarOptionFrame:SetHidden(true)
  10.         end
  11.     end
  12. end)

Here is the entire lua code I have so far remember I'm still working on this so it's not finished at all yet.

Lua Code:
  1. --Want to add Show Hide function for each window. ( barQWindow, barAWindow, barMWindow, barCWindow )
  2. --With the Show Hide I want to add this in an addon options window.
  3. --Want to add a lock frame for each window.
  4. --With lock frame I want to add this in an addon options window.
  5.  
  6. --Create a button using lua that pulls up a window for ZBar Options.
  7.  
  8. -- creates a generic button in the middle of the screen --
  9. ZBarButton = CreateFrame("Button","ZBarButton",UIParent,"UIPanelButtonTemplate")
  10. ZBarButton:SetPoint("CENTER",0,0)
  11. ZBarButton:SetWidth(30)
  12. ZBarButton:SetHeight(30)
  13. ZBarButton:SetText("ZB")
  14. ZBarButton:SetMovable(true)
  15. ZBarButton:RegisterForDrag("LeftButton")
  16. ZBarButton:SetScript("OnDragStart",ZBarButton.StartMoving)
  17. ZBarButton:SetScript("OnDragStop",ZBarButton.StopMovingOrSizing)
  18.  
  19. ZBarOptionFrame = CreateFrame("Frame")
  20. ZBarOptionFrame:ClearAllPoints()
  21. ZBarOptionFrame:SetBackdrop(StaticPopup1:GetBackdrop())
  22. ZBarOptionFrame:SetHeight(300)
  23. ZBarOptionFrame:SetWidth(300)
  24. ZBarOptionFrame:SetHidden(true)
  25.  
  26. ZBarOptionFrame.text = ZBarOptionFrame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
  27. ZBarOptionFrame.text:SetAllPoints()
  28. ZBarOptionFrame.text:SetText("ZBar Options Verison 1.0")
  29. ZBarOptionFrame:SetPoint("CENTER", 0, 0)
  30.  
  31. local frame = CreateFrame("Button", ZBarOptionFrame, UIParent)
  32.  
  33. ZBarOptionFrame:RegisterForClicks("AnyUp")
  34. ZBarOptionFrame:SetScrpit("OnClick", function(self, button, ...)
  35.     if (button == "RightButton") then
  36.         if ZBarOptionFrame:IsShown() then
  37.             ZBarOptionFrame:SetHidden(false)
  38.         else
  39.             ZBarOptionFrame:SetHidden(true)
  40.         end
  41.     end
  42. end)

Please if you write code back to me show it completely with all information and deep examples. I'm still very new to coding.
  Reply With Quote