I don't understand this behaviour. If I comment out all the lines after line 47 the GUI frame shows up and works. I can enter text in the MultiLineEditBox and the Convert button does what it is supposed to do. However, as soon as I enable the slash command code the GUI frame loses all its child frames.
The slash command does toggle the GUI frame as expected, it is just that the child frames don't appear unless I comment out the slash command code.
Anyone have ideas?
Lua Code:
local title, addon = ...
local L = addon.L
local gui = LibStub("AceGUI-3.0")
local text_store = "" -- store the edit box text
-- create the GUI and make it useful
local main_frame = gui:Create("Frame")
main_frame:SetTitle(L["TSM String Converter"])
main_frame:SetStatusText(L["TradeSkillMaster itemID String Fixer"])
main_frame:SetCallback("OnClose", function(widget)
text_store = ""
gui:Release(widget)
end)
main_frame:SetLayout("Flow")
local edit_box = gui:Create("MultiLineEditBox")
edit_box:SetLabel(L["Insert itemIDs"])
edit_box:SetRelativeWidth(1.0)
edit_box:SetNumLines(25)
edit_box:SetMaxLetters(0) -- no limit to the number of characters entered
edit_box:DisableButton(true) -- disables the "Okay" button
edit_box:SetCallback("OnTextChanged", function(widget, event, text)
edit_box:SetLabel(L["Insert itemIDs"])
text_store = text
end)
main_frame:AddChild(edit_box)
local button = gui:Create("Button")
button:SetText(CONVERT)
button:SetRelativeWidth(1.0)
button:SetCallback("OnClick", function()
-- strip out all spaces, just in case
text_store = text_store:trim()
text_store = string.gsub(text_store, " ", "")
-- break text_store entirely, and fix it (credit to krowbar71 on the Wowinterface forums)
text_store = string.gsub(string.gsub(text_store, "[iI]:", ""), "(%d+)", "i:%1")
print("|cff32cd32TSMSC: |r" .. DONE_EDITING)
edit_box:SetText(text_store)
edit_box:HighlightText()
edit_box:SetFocus()
edit_box:SetLabel(DONE_EDITING)
end)
main_frame:AddChild(button)
--[[
local f = CreateFrame("Frame") -- for events
function addon:PLAYER_ENTERING_WORLD()
if main_frame:IsShown() then
main_frame:Hide()
end
end
-- create and handle slash command
SLASH_TSMSC1 = L["/tsmsc"]
SlashCmdList["TSMSC"] = function(msg, editBox) -- the edit box that originated the command, not the input field for itemIDs
if main_frame:IsShown() then
main_frame:Hide()
else
main_frame:Show()
end
end
f:SetScript("OnEvent", function(self, event, ...)
addon[event](self, ...) -- call one of the functions above
end)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
]]--