Thread Tools Display Modes
04-29-14, 07:56 PM   #1
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Couple Questions: Fatal Exception Error #132 Button:SetNormalTexture() & Textures

I am working on a GUI and I tried to make a button that when you click on it, the normal texture changes from unlocked to locked and vice versa. However, when I click it when it's "unlocking" it gives me this fatal error and my game crashes.

Also, I cannot figure out how to use the SetTexCoords right for the artwork on my main frame so that my frame can be the size of the artwork. You see in the screenshot all the blue space is the frame and if I tried making the height smaller it would just push the artwork up and make it funky and when I set coordinates, it didn't seem to work for me.

Finally, I've been writing bits and then going back and trying to improve them as I go but I still am trying to figure out what is efficient and what's not (and how to make as little code as possible for the repetitive parts). So any pointers in the right direction for that would be helpful.



Main chunk:
lua Code:
  1. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  2. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  3. -- -- -- -- Lazy Leader by Niketa -- -- -- --
  4. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  5. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  6.  
  7. local addon, ns = ...
  8. local L = ns.Localization
  9.  
  10. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  11. -- MainFrame
  12. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  13. ns.MainFrame =  CreateFrame("Frame", addon .. "MainFrame", UIParent)
  14. local MainFrame = ns.MainFrame
  15.       MainFrame:SetScript("OnEvent", function(self, event, ...)
  16.         return self[event] and self[event](self, event, ...)
  17.       end)
  18.  
  19. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  20. -- Functions
  21. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  22. -- -- Slash Commands -- --
  23. SLASH_LAZYLEADER1, SLASH_LAZYLEADER2 = "/lazy", "/lazylead"
  24.  
  25. function SlashCmdList.LAZYLEADER(msg)
  26.     if MainFrame:IsVisible() then
  27.         MainFrame:Hide()
  28.     else
  29.         MainFrame:Show()
  30.     end
  31. end
  32.  
  33. -- -- DisplayTabFrames -- --
  34. function MainFrame:DisplayTabFrames(tab, subtab)
  35.     subtab = subtab or 1
  36.  
  37.     for k, v in pairs(MainFrame.Tabs) do
  38.         -- Hide Content
  39.         for key, value in pairs(MainFrame.Tabs[k].subtabs) do
  40.             value.sidebar.subtab:UnlockHighlight()
  41.             for K, V in pairs(value.elements) do
  42.                 V:Hide()
  43.             end
  44.             for K, V in pairs(value.sidebar) do
  45.                 V:Hide()
  46.             end
  47.         end
  48.  
  49.         -- Show Content
  50.         if k == tab then
  51.             for key, value in pairs(MainFrame.Tabs[tab].subtabs) do
  52.                 for K, V in pairs(value.sidebar) do
  53.                     V:Show()
  54.                 end
  55.                 -- print(key, value)
  56.             end
  57.             for key, value in pairs(MainFrame.Tabs[k].subtabs) do
  58.                 if key == subtab then
  59.                     value.sidebar.subtab:LockHighlight()
  60.                     for K, V in pairs(MainFrame.Tabs[k].subtabs[key].elements) do
  61.                         V:Show()
  62.                     end
  63.                 end
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69.  
  70. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  71. -- MainFrame Display
  72. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  73. MainFrame:EnableMouse(true)
  74. MainFrame:SetMovable(true)
  75. MainFrame:SetSize(768, 512)
  76. MainFrame:SetPoint("CENTER",0,0)
  77.  
  78. local temp = MainFrame:CreateTexture(nil, "BACKGROUND")
  79.       temp:SetAllPoints(MainFrame)
  80.       temp:SetTexture(0, 0, 1, 1)
  81.  
  82. -- -- Title Region -- --
  83. local TitleRegion = MainFrame:CreateTitleRegion()
  84.       TitleRegion:SetPoint("CENTER", MainFrame, "TOP", 0, -15)
  85.       TitleRegion:SetSize(768, 20)
  86.  
  87. local Title = MainFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  88.       Title:SetText(GetUnitName("player") .. ", " .. L["the Lazy Leader"])
  89.       Title:SetPoint("TOPLEFT", 80, -19)
  90.  
  91. -- -- Artwork Textures -- --
  92. MainFrame.Textures = {
  93.     {point = "TOPLEFT", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "BROWSE-TOPLEFT"},
  94.     {point = "TOP", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "BROWSE-TOP"},
  95.     {point = "TOPRIGHT", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "BROWSE-TOPRIGHT"},
  96.     {point = "BOTTOMLEFT", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "BROWSE-BOTLEFT"},
  97.     {point = "BOTTOM", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "AUCTION-BOT"},
  98.     {point = "BOTTOMRIGHT", folder = "AUCTIONFRAME", prefix = "AUCTIONFRAME", file = "AUCTION-BOTRIGHT"},
  99. }
  100.  
  101. for k, v in pairs(MainFrame.Textures) do
  102.     local texture = MainFrame:CreateTexture(nil, "ARTWORK")
  103.           texture:SetTexture("Interface\\" .. v.folder .. "\\UI-" .. v.prefix .. "-" .. v.file .. ".BLP")
  104.           texture:SetPoint(v.point, 0, 0)
  105. end
  106.  
  107. -- Portrait --
  108. local Portrait = MainFrame:CreateTexture(nil, "BACKGROUND")
  109.       Portrait:SetHeight(60)
  110.       Portrait:SetWidth(60)
  111.       Portrait:SetPoint("TOPLEFT", 8, -8)
  112.       SetPortraitTexture(Portrait, "player")
  113.  
  114. -- -- Close Button -- --
  115. local CloseBTN = CreateFrame("Button", nil, MainFrame, "UIPanelCloseButton")
  116.       CloseBTN:SetPoint("TOPRIGHT", 3, -8)
  117.  
  118. -- -- Snapshot Button -- --
  119. local SnapshotBTN = CreateFrame("Button", nil, MainFrame, "UIPanelButtonTemplate")
  120.       SnapshotBTN:SetWidth(123)
  121.       SnapshotBTN:SetHeight(26)
  122.       SnapshotBTN:SetNormalFontObject(GameFontNormalSmall)
  123.       SnapshotBTN:SetHighlightFontObject(GameFontHighlightSmall)
  124.       SnapshotBTN:SetPushedTextOffset(0, 0)
  125.       SnapshotBTN:SetText(L["Take a Snapshot"])
  126.       SnapshotBTN:SetPoint("BOTTOMRIGHT", MainFrame, "BOTTOMRIGHT", -87, 78)
  127.       SnapshotBTN:SetScript("OnClick", function()
  128.         print("Snapshot taken!!")
  129.       end)
  130.  
  131. -- -- Invite Button -- --
  132. local InviteBTN = CreateFrame("Button", nil, MainFrame, "UIPanelButtonTemplate")
  133.       InviteBTN:SetWidth(78)
  134.       InviteBTN:SetHeight(26)
  135.       InviteBTN:SetNormalFontObject(GameFontNormalSmall)
  136.       InviteBTN:SetHighlightFontObject(GameFontHighlightSmall)
  137.       InviteBTN:SetPushedTextOffset(0, 0)
  138.       InviteBTN:SetText(L["Invite"])
  139.       InviteBTN:SetPoint("BOTTOMRIGHT", MainFrame, "BOTTOMRIGHT", -7, 78)
  140.       InviteBTN:SetScript("OnClick", function()
  141.         print("Inviting friends...")
  142.       end)
  143.  
  144. -- -- Tab Buttons -- --
  145. MainFrame.Tabs = {
  146.     {
  147.         name = L["Welcome"],
  148.         description = L["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ac mi non nibh pellentesque malesuada. Proin vel est interdum, pretium enim quis, blandit odio. Phasellus rhoncus dolor magna, eu convallis sapien eleifend luctus. Phasellus vehicula enim ac purus pharetra, id pretium nisi sagittis. Vestibulum non est congue, posuere lorem eget, varius sapien. Integer ornare massa at mi suscipit aliquam. Cras aliquam venenatis justo, ut porta diam tincidunt nec. Cras pellentesque aliquet quam ut gravida. Fusce et sem ac nibh viverra tristique ac nec elit. Proin posuere hendrerit enim vel adipiscing. Phasellus mollis porta vehicula. Sed dapibus quam nibh, quis tristique neque sodales a. Etiam tortor felis, pellentesque id nibh ac, vehicula auctor est. Etiam odio tortor, faucibus a dolor eget, cursus egestas arcu. Nulla eget consequat neque."],
  149.         subtabs = {
  150.             {name = L["Introduction"], sidebar = {}, elements = {}}
  151.         }
  152.     },
  153.     {
  154.         name = L["Raiders"],
  155.         description = L["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ac mi non nibh pellentesque malesuada. Proin vel est interdum, pretium enim quis, blandit odio. Phasellus rhoncus dolor magna, eu convallis sapien eleifend luctus. Phasellus vehicula enim ac purus pharetra, id pretium nisi sagittis. Vestibulum non est congue, posuere lorem eget, varius sapien. Integer ornare massa at mi suscipit aliquam. Cras aliquam venenatis justo, ut porta diam tincidunt nec. Cras pellentesque aliquet quam ut gravida. Fusce et sem ac nibh viverra tristique ac nec elit. Proin posuere hendrerit enim vel adipiscing. Phasellus mollis porta vehicula. Sed dapibus quam nibh, quis tristique neque sodales a. Etiam tortor felis, pellentesque id nibh ac, vehicula auctor est. Etiam odio tortor, faucibus a dolor eget, cursus egestas arcu. Nulla eget consequat neque."],
  156.         subtabs = {
  157.             {name = L["Introduction"], sidebar = {}, elements = {}},
  158.             {name = L["Add Friends"], sidebar = {}, elements = {}},
  159.             {name = L["Invite Friends"], sidebar = {}, elements = {}}
  160.         }
  161.     },
  162.     {
  163.         name = L["History"],
  164.         description = L["This is a tab page!"],
  165.         subtabs = {
  166.             {name = L["Introduction"], sidebar = {}, elements = {}},
  167.             {name = L["Snapshots"], sidebar = {}, elements = {}}
  168.         }
  169.     },
  170.     {
  171.         name = L["Settings"],
  172.         description = L["This is a tab page!"],
  173.         subtabs = {
  174.             {name = L["Introduction"], sidebar = {}, elements = {}},
  175.             {name = L["Settings"], sidebar = {}, elements = {}}
  176.         }
  177.     },
  178.     {
  179.         name = L["Help"],
  180.         description = L["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus nisi, faucibus sed ante non, scelerisque egestas odio. Nunc rhoncus felis vitae nisl rhoncus sollicitudin. Cras tristique eros at dui placerat egestas. Sed consequat, quam in rutrum vulputate, quam eros condimentum dui, a ornare lectus dolor vitae felis. Suspendisse egestas magna id congue volutpat. Donec ante ligula, venenatis vitae porttitor nec, fermentum at sapien. Integer diam mauris, laoreet a nunc eu, rutrum dignissim nisi. Suspendisse interdum purus diam, eu mattis nisi aliquam ac. Duis euismod lobortis ultrices. Mauris suscipit dui vitae nibh semper dictum.\n\nNullam mattis iaculis lorem in eleifend. Donec eget lectus tellus. Quisque ultricies metus at adipiscing pellentesque. Integer vitae consectetur tellus. Praesent eu nibh id justo porta ultrices. Suspendisse ligula nisi, vehicula gravida lobortis quis, mattis sit amet sem. Sed vel libero quis nibh iaculis pretium. Mauris eu tellus semper, eleifend metus a, tincidunt felis. Sed tempus quam malesuada, sagittis odio quis, pretium eros. Morbi sollicitudin massa vitae diam lacinia commodo.\n\nMauris consectetur nisi at vehicula gravida. Integer euismod metus suscipit faucibus dapibus. Pellentesque sit amet elit sem. Mauris convallis lorem a mauris tempus porttitor varius non risus. Aenean velit ante, pretium pellentesque sem sollicitudin, malesuada consequat eros. In vitae sagittis nisi. Mauris odio libero, fringilla ac blandit sit amet, ultricies eget justo. Etiam pulvinar posuere ante, eu porta elit mollis at. Fusce placerat sed est in ullamcorper. Ut non fringilla ipsum. Ut nec augue non mauris sollicitudin mollis volutpat viverra odio. Cras ornare dui mauris, quis pulvinar nulla cursus sed. In id neque ante. Praesent aliquam, sem sit amet mollis dignissim, sapien mi hendrerit risus, a ornare magna augue id tortor."],
  181.         subtabs = {
  182.             {name = L["Introduction"], sidebar = {}, elements = {}}
  183.         }
  184.     },
  185. }
  186.  
  187. for k, v in pairs(MainFrame.Tabs) do
  188.     local tab = CreateFrame("Button", "tab" .. k, MainFrame, "OptionsFrameTabButtonTemplate")
  189.           tab:SetText(v.name)
  190.           PanelTemplates_TabResize(tab, 0)
  191.  
  192.     if k == 1 then
  193.         tab:SetPoint("TOPLEFT", 192, -75)
  194.     else
  195.         tab:SetPoint("TOPLEFT", "tab" .. (k - 1), "TOPRIGHT", -7, 0)
  196.     end
  197.  
  198.     tab:SetScript("OnClick", function()
  199.         MainFrame:DisplayTabFrames(k)
  200.     end)
  201. end
  202.  
  203. -- -- Content Window -- --
  204. local ScrollFrame = CreateFrame("ScrollFrame", "MainFrameContentScrollFrame", MainFrame, "UIPanelScrollFrameTemplate")
  205.       ScrollFrame:SetSize(540, 300)
  206.       ScrollFrame:SetPoint("TOPLEFT", 192, -105)
  207.  
  208. ScrollFrame.ScrollBar:EnableMouseWheel(true)
  209. ScrollFrame.ScrollBar:SetScript("OnMouseWheel", function(self, direction)
  210.     ScrollFrameTemplate_OnMouseWheel(ScrollFrame, direction)
  211. end)
  212.  
  213. local ScrollFrameBG = ScrollFrame:CreateTexture(nil, "BACKGROUND", nil, -6)
  214.       ScrollFrameBG:SetPoint("TOP")
  215.       ScrollFrameBG:SetPoint("RIGHT", 25, 0)
  216.       ScrollFrameBG:SetPoint("BOTTOM")
  217.       ScrollFrameBG:SetWidth(26)
  218.       ScrollFrameBG:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar.blp")
  219.       ScrollFrameBG:SetTexCoord(0, 0.45, 0.1640625, 1)
  220.       ScrollFrameBG:SetAlpha(0.5)
  221.  
  222. MainFrame.ContentScrollFrame = ScrollFrame
  223.  
  224. ns.ScrollContent = CreateFrame("Frame", nil, ScrollFrame)
  225. local ScrollContent = ns.ScrollContent
  226.       ScrollContent:SetSize(ScrollFrame:GetWidth(), ScrollFrame:GetHeight())
  227.  
  228. -- local temp = ScrollContent:CreateTexture(nil, "BACKGROUND")
  229. --    temp:SetAllPoints(ScrollContent)
  230. --    temp:SetTexture(0, 0, 1, 1)
  231.  
  232. ScrollFrame:SetScrollChild(ScrollContent)
  233.  
  234. -- -- Subtab Frame -- --
  235. local SubTabFrame = CreateFrame("Frame", nil, MainFrame)
  236.       SubTabFrame:SetSize(155, 300)
  237.       SubTabFrame:SetPoint("TOPLEFT", 24, -105)
  238.  
  239. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  240. -- Description Tab Displays
  241. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  242. for k, v in pairs(MainFrame.Tabs) do
  243.     MainFrame.Tabs[k].subtabs[1].elements.title = ScrollContent:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
  244.     local title = MainFrame.Tabs[k].subtabs[1].elements.title
  245.           title:SetText(MainFrame.Tabs[k].name)
  246.           title:SetPoint("TOPLEFT", 10, -8)
  247.  
  248.     MainFrame.Tabs[k].subtabs[1].elements.description = ScrollContent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  249.     local description = MainFrame.Tabs[k].subtabs[1].elements.description
  250.           description:SetWidth(520)
  251.           description:CanWordWrap(true)
  252.           description:SetJustifyH("LEFT")
  253.           description:SetText(MainFrame.Tabs[k].description)
  254.           description:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -5)
  255.  
  256.     for key, value in pairs(MainFrame.Tabs[k].subtabs) do
  257.         if key ~= 1 then
  258.             MainFrame.Tabs[k].subtabs[key].elements.title = ScrollContent:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
  259.             local title = MainFrame.Tabs[k].subtabs[key].elements.title
  260.                   title:SetText(MainFrame.Tabs[k].subtabs[key].name)
  261.                   title:SetPoint("TOPLEFT", 10, -8)
  262.         end
  263.     end
  264. end
  265.  
  266. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  267. -- Sidebar Tab Display
  268. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  269. for k, v in pairs(MainFrame.Tabs) do
  270.     for key, value in pairs(MainFrame.Tabs[k].subtabs) do
  271.         MainFrame.Tabs[k].subtabs[key].sidebar.subtab = CreateFrame("Button", "subtab" .. key, SubTabFrame)
  272.         local subtab = MainFrame.Tabs[k].subtabs[key].sidebar.subtab
  273.               subtab:SetNormalFontObject("GameFontHighlightSmall")
  274.               subtab:SetText(MainFrame.Tabs[k].subtabs[key].name)
  275.               subtab:SetSize(SubTabFrame:GetWidth(), 23)
  276.  
  277.         local subtabtext = subtab:GetFontString()
  278.               subtabtext:ClearAllPoints()
  279.               subtabtext:SetJustifyH("LEFT")
  280.               subtabtext:SetPoint("LEFT", subtab, 8, 0)
  281.               subtabtext:SetPoint("RIGHT", subtab, -8, 0)
  282.  
  283.         local nTexture = subtab:CreateTexture()
  284.               nTexture:SetTexture("Interface\\AUCTIONFRAME\\UI-AuctionFrame-FilterBG.blp")
  285.               nTexture:SetTexCoord(0, 0.53125, 0, 0.625)
  286.               nTexture:SetAllPoints(subtab)
  287.               subtab:SetNormalTexture(nTexture)
  288.  
  289.         local hTexture = subtab:CreateTexture()
  290.               hTexture:SetTexture("Interface\\Buttons\\UI-SILVER-BUTTON-HIGHLIGHT.BLP")
  291.               hTexture:SetPoint("TOPLEFT", subtab, "TOPLEFT", 5, 0)
  292.               hTexture:SetPoint("BOTTOMRIGHT", subtab, "BOTTOMRIGHT", -5, -3)
  293.               subtab:SetHighlightTexture(hTexture)
  294.  
  295.         if key == 1 then
  296.             subtab:SetPoint("TOPLEFT")
  297.         else
  298.             subtab:SetPoint("TOPLEFT", "subtab" .. (key - 1), "BOTTOMLEFT", 0, -2)
  299.         end
  300.  
  301.         -- OnClick
  302.         subtab:SetScript("OnClick", function()
  303.             MainFrame:DisplayTabFrames(k, key)
  304.         end)
  305.     end
  306. end

The page where the error occurs (ToggleDeleteLock OnClick)
lua Code:
  1. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  2. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  3. -- -- -- -- Lazy Leader by Niketa -- -- -- --
  4. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  5. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  6.  
  7. local addon, ns = ...
  8. local L = ns.Localization
  9.  
  10. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  11. -- History Tab Display
  12. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  13. local tab = 3
  14.  
  15. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  16. -- Snapshot Subtab Display
  17. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  18. local subtabtable = ns.MainFrame.Tabs[tab].subtabs[2]
  19. local elements = subtabtable.elements
  20.  
  21. -- -- Dropdown Snapshot Select Menu -- --
  22. local Snapshots = {["Dragon Soul"] = {"04/19/2014", "04/26/2014"}, ["Siege of Orgrimmar"] = {"04/18/2014", "04/25/2014"}}
  23. local lock = 0
  24. local raid, date = ""
  25.  
  26. elements.DropSnapshot = CreateFrame("Frame", "DropSnapshot", ns.ScrollContent, "UIDropDownMenuTemplate")
  27. local DropSnapshot = elements.DropSnapshot
  28.       DropSnapshot:SetPoint("TOPLEFT", elements.title, "BOTTOMLEFT", -10, -15)
  29.  
  30. UIDropDownMenu_SetWidth(DropSnapshot, 200)
  31. UIDropDownMenu_SetText(DropSnapshot, L["Select a Snapshot"])
  32. UIDropDownMenu_Initialize(DropSnapshot, function(self, level, menuList)
  33.     local info = UIDropDownMenu_CreateInfo()
  34.  
  35.     if (level or 1) == 1 then
  36.         for k, v in pairs(Snapshots) do
  37.             info.text, info.checked = k, raid == k
  38.             info.menuList, info.hasArrow = k, true
  39.             UIDropDownMenu_AddButton(info)
  40.         end
  41.     else
  42.         info.func = self.SetValue
  43.         for k, v in pairs(Snapshots[menuList]) do
  44.             info.text, info.arg1, info.arg2, info.checked = v, menuList, v, v == date
  45.             UIDropDownMenu_AddButton(info, level)
  46.         end
  47.     end
  48. end)
  49.  
  50. function DropSnapshot:SetValue(selectraid, selectdate)
  51.     raid = selectraid
  52.     date = selectdate
  53.     UIDropDownMenu_SetText(DropSnapshot, raid .. ": " .. date)
  54.     CloseDropDownMenus()
  55.     elements.DeleteBTN:Enable()
  56. end
  57.  
  58. -- -- Delete Snapshot Button -- --
  59. StaticPopupDialogs[addon .. "DeleteBTNConfirmation"] = {
  60.     text = L["Are you sure you want to delete the snapshot " .. (raid ~= "" and raid or "") .. "?"],
  61.     button1 = L["Delete"],
  62.     button2 = L["Cancel"],
  63.     OnAccept = function()
  64.         print("Deleted " .. (raid ~= "" and raid or ""))
  65.     end,
  66.     whileDead = true,
  67.     preferredIndex = 3
  68. }
  69.  
  70. elements.DeleteBTN = CreateFrame("Button", nil, ns.ScrollContent)
  71. local DeleteBTN = elements.DeleteBTN
  72.       DeleteBTN:SetWidth(20)
  73.       DeleteBTN:SetHeight(20)
  74.       DeleteBTN:SetPoint("TOPLEFT", elements.DropSnapshot, "TOPRIGHT", 0, -5)
  75.       DeleteBTN:SetScript("OnClick", function()
  76.         StaticPopup_Show (addon .. "DeleteBTNConfirmation")
  77.       end)
  78.       DeleteBTN:Disable()
  79.  
  80. -- Textures
  81. local nTexture = DeleteBTN:CreateTexture()
  82.       nTexture:SetTexture("Interface\\Buttons\\UI-MinusButton-Up.blp")
  83.       nTexture:SetAllPoints(DeleteBTN)
  84. DeleteBTN:SetNormalTexture(nTexture)
  85.  
  86. local pTexture = DeleteBTN:CreateTexture()
  87.       pTexture:SetTexture("Interface\\Buttons\\UI-MinusButton-Down.blp")
  88.       pTexture:SetAllPoints(DeleteBTN)
  89. DeleteBTN:SetPushedTexture(pTexture)
  90.  
  91. local dTexture = DeleteBTN:CreateTexture()
  92.       dTexture:SetTexture("Interface\\Buttons\\UI-MinusButton-Disabled.blp")
  93.       dTexture:SetAllPoints(DeleteBTN)
  94. DeleteBTN:SetDisabledTexture(dTexture)
  95.  
  96. -- -- Delete Snapshot Button Confirmation Lock Toggle -- --
  97. elements.ToggleDeleteLock = CreateFrame("Button", nil, ns.ScrollContent)
  98. local ToggleDeleteLock = elements.ToggleDeleteLock
  99.       ToggleDeleteLock:SetSize(26, 26)
  100.       ToggleDeleteLock:SetPoint("TOPLEFT", DeleteBTN, "TOPRIGHT", 5, 3)
  101.  
  102. -- Textures
  103. local nTexture = ToggleDeleteLock:CreateTexture()
  104.       nTexture:SetTexture("Interface\\Buttons\\LockButton-Unlocked-Up.blp")
  105.       nTexture:SetAllPoints(ToggleDeleteLock)
  106. ToggleDeleteLock:SetNormalTexture(nTexture)
  107.  
  108. local pTexture = ToggleDeleteLock:CreateTexture()
  109.       pTexture:SetTexture("Interface\\Buttons\\LockButton-Unlocked-Down.blp")
  110.       pTexture:SetAllPoints(ToggleDeleteLock)
  111. ToggleDeleteLock:SetPushedTexture(pTexture)
  112.  
  113. local lTexture = ToggleDeleteLock:CreateTexture()
  114.       lTexture:SetTexture("Interface\\Buttons\\LockButton-Locked-Up.blp")
  115.       lTexture:SetAllPoints(ToggleDeleteLock)
  116.  
  117. -- OnClick
  118. ToggleDeleteLock:SetScript("OnClick", function()
  119.     if lock == 1 then
  120.         lock = 0
  121.         -- ToggleDeleteLock:SetNormalTexture(nTexture)
  122.     elseif lock == 0 then
  123.         lock = 1
  124.         -- ToggleDeleteLock:SetNormalTexture(lTexture)
  125.     end
  126. end)
  127.  
  128. -- Text
  129. elements.ToggleDeleteLockText = ToggleDeleteLock:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  130. local ToggleDeleteLockText = elements.ToggleDeleteLockText
  131.       ToggleDeleteLockText:SetText(L["Confirm Snapshot Deletion"])
  132.       ToggleDeleteLockText:SetPoint("TOPLEFT", ToggleDeleteLock, "TOPRIGHT", 5, -6)
  Reply With Quote
04-29-14, 09:13 PM   #2
Malakahh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 30
Having spent a little time looking over your code, I can't pinpoint the exact issue.

The error you're getting suggests that a pointer tries to access some memory that it shouldn't, which to me suggests that there's a dead reference somewhere in your code.

A blind guess would be that your OnClick, for some reason, doesn't have a reference to nTexture even though it should. I notice you're creating a variable named nTexture twice, not once followed by an override. Even though this should be fine to my knowledge, maybe that is the cause of the missing reference? Try renaming the second nTexture variable to something else, and see if that fixes the issue.

This is however a far shot, and I haven't been able to reproduce anything using an interpreter.
  Reply With Quote
04-29-14, 09:50 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
:SetPushedTexture(), :SetNormalTexture() and :SetDisabledTexture() can take a texture string for the argument, you don't need to create the actual texture object. Try doing that instead.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-29-14, 11:09 PM   #4
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Looks like that did the trick for the crash, Seerah. Malakahh, I didn't test what you said out but my guess is that may have been the cause and either renaming or setting the textures directly would have fixed it. Thank you both for the quick responses.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Couple Questions: Fatal Exception Error #132 Button:SetNormalTexture() & Textures

Thread Tools
Display Modes

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