Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-13-19, 11:52 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
my slash command code conflicts with the frame

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:
  1. local title, addon = ...
  2. local L = addon.L
  3. local gui = LibStub("AceGUI-3.0")
  4.  
  5. local text_store = "" -- store the edit box text
  6.  
  7. -- create the GUI and make it useful
  8. local main_frame = gui:Create("Frame")
  9. main_frame:SetTitle(L["TSM String Converter"])
  10. main_frame:SetStatusText(L["TradeSkillMaster itemID String Fixer"])
  11. main_frame:SetCallback("OnClose", function(widget)
  12.     text_store = ""
  13.     gui:Release(widget)
  14. end)
  15. main_frame:SetLayout("Flow")
  16.  
  17. local edit_box = gui:Create("MultiLineEditBox")
  18. edit_box:SetLabel(L["Insert itemIDs"])
  19. edit_box:SetRelativeWidth(1.0)
  20. edit_box:SetNumLines(25)
  21. edit_box:SetMaxLetters(0) -- no limit to the number of characters entered
  22. edit_box:DisableButton(true) -- disables the "Okay" button
  23. edit_box:SetCallback("OnTextChanged", function(widget, event, text)
  24.     edit_box:SetLabel(L["Insert itemIDs"])
  25.     text_store = text
  26. end)
  27. main_frame:AddChild(edit_box)
  28.  
  29. local button = gui:Create("Button")
  30. button:SetText(CONVERT)
  31. button:SetRelativeWidth(1.0)
  32. button:SetCallback("OnClick", function()
  33.     -- strip out all spaces, just in case
  34.     text_store = text_store:trim()
  35.     text_store = string.gsub(text_store, " ", "")
  36.  
  37.     -- break text_store entirely, and fix it (credit to krowbar71 on the Wowinterface forums)
  38.     text_store = string.gsub(string.gsub(text_store, "[iI]:", ""), "(%d+)", "i:%1")
  39.  
  40.     print("|cff32cd32TSMSC: |r" .. DONE_EDITING)
  41.  
  42.     edit_box:SetText(text_store)
  43.     edit_box:HighlightText()
  44.     edit_box:SetFocus()
  45.     edit_box:SetLabel(DONE_EDITING)
  46. end)
  47. main_frame:AddChild(button)
  48.  
  49. --[[
  50. local f = CreateFrame("Frame") -- for events
  51.  
  52. function addon:PLAYER_ENTERING_WORLD()
  53.     if main_frame:IsShown() then
  54.         main_frame:Hide()
  55.     end
  56. end
  57.  
  58.  
  59. -- create and handle slash command
  60. SLASH_TSMSC1 = L["/tsmsc"]
  61. SlashCmdList["TSMSC"] = function(msg, editBox) -- the edit box that originated the command, not the input field for itemIDs
  62.     if main_frame:IsShown() then
  63.         main_frame:Hide()
  64.     else
  65.         main_frame:Show()
  66.     end
  67. end
  68.  
  69. f:SetScript("OnEvent", function(self, event, ...)
  70.     addon[event](self, ...) -- call one of the functions above
  71. end)
  72.  
  73. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  74. ]]--
Attached Thumbnails
Click image for larger version

Name:	no slash command.jpg
Views:	151
Size:	31.5 KB
ID:	9198  Click image for larger version

Name:	with slash command.jpg
Views:	139
Size:	49.5 KB
ID:	9199  
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » my slash command code conflicts with the frame


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