Thread: AceGUI help
View Single Post
10-01-20, 08:32 AM   #2
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Nevermind

I figured it out. I guess all I needed to do was sleep so I could think clearly. The solution was to take the outer tree out of the scrollframe and add a scrollframe to the tree's container group instead. Fixed both problems.

The updated code, for anyone in the future having the same issues:
Lua Code:
  1. function addon:CreateObjectiveBuilder()
  2.     -- self:AddTestDBValues()
  3.  
  4.     local frame = AceGUI:Create("Frame")
  5.     frame:SetTitle(L._ObjectiveBuilder("title"))
  6.     frame:SetWidth(600)
  7.     frame:SetHeight(525)
  8.     frame:SetLayout("Fill")
  9.  
  10.     self.ObjectiveBuilder = frame
  11.  
  12.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  13.  
  14.     local objectiveTree = AceGUI:Create("TreeGroup")
  15.     objectiveTree:SetFullHeight(true)
  16.     objectiveTree:SetLayout("Flow")
  17.     objectiveTree:SetTree(self:GetObjectiveTree())
  18.     frame:AddChild(objectiveTree)
  19.  
  20.     objectiveTree:SetCallback("OnGroupSelected", function(container, _, selected)
  21.         container:ReleaseChildren()
  22.  
  23.         if selected == "newObjective" then
  24.             print("Create a new objective.")
  25.         else
  26.             -- Finding out the selected path to get the objectiveTitle
  27.             -- Not conerned with ever clicking on Active/Inactive itself
  28.             local objectiveTitle = {strsplit("\001", selected)}
  29.             tremove(objectiveTitle, 1)
  30.             objectiveTitle = strjoin("?", unpack(objectiveTitle))
  31.  
  32.             if objectiveTitle ~= "" then
  33.                 addon:DrawObjectiveGroup(container, objectiveTitle)
  34.             end
  35.         end
  36.     end)
  37.  
  38.     objectiveTree:SelectByPath("Active")
  39. end
  40.  
  41. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  42.  
  43. function addon:DrawObjectiveGroup(group, objectiveTitle)
  44.     local objectiveInfo = self.db.global.objectives[objectiveTitle]
  45.     group.objectiveTitle = objectiveTitle
  46.  
  47.     -- Need to redraw again for when icon editbox/button are shown and hidden
  48.     group:ReleaseChildren()
  49.  
  50.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  51.     -- groupScrollContainer
  52.  
  53.     local groupScrollContainer = AceGUI:Create("SimpleGroup")
  54.     groupScrollContainer:SetFullWidth(true)
  55.     groupScrollContainer:SetFullHeight(true)
  56.     groupScrollContainer:SetLayout("Fill")
  57.     group:AddChild(groupScrollContainer)
  58.  
  59.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60.     -- groupScrollFrame
  61.  
  62.     local groupScrollFrame = AceGUI:Create("ScrollFrame")
  63.     groupScrollFrame:SetFullWidth(true)
  64.     groupScrollFrame:SetLayout("Flow")
  65.     groupScrollContainer:AddChild(groupScrollFrame)
  66.  
  67.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  68.     -- titleEditBox
  69.  
  70.     local titleEditBox = AceGUI:Create("EditBox")
  71.     titleEditBox:SetFullWidth(true)
  72.     titleEditBox:SetLabel(L["Title"])
  73.     titleEditBox:SetText(group.objectiveTitle)
  74.     groupScrollFrame:AddChild(titleEditBox)
  75.  
  76.     titleEditBox:SetCallback("OnEnterPressed", function(self)
  77.         local success, err = addon:UpdateObjectiveTitle(group.objectiveTitle, self:GetText())
  78.  
  79.         self:ClearFocus()
  80.  
  81.         if err and err == "exists" then
  82.             -- If err is because objective exists, restore title, focus and highlight for user to change
  83.             -- The other err would be because the title hasn't changed
  84.             self:SetText(group.objectiveTitle)
  85.             self:SetFocus()
  86.             self:HighlightText()
  87.         elseif success then
  88.             -- Update the objectiveTree to repopulate objectiveTitles
  89.             group:SetTree(addon:GetObjectiveTree())
  90.             -- Update the container's title reference
  91.             group.objectiveTitle = self:GetText()
  92.         end
  93.     end)
  94.  
  95.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  96.     -- autoIconCheckBox
  97.  
  98.     local autoIconCheckBox = AceGUI:Create("CheckBox")
  99.     autoIconCheckBox:SetType("checkbox")
  100.     autoIconCheckBox:SetFullWidth(true)
  101.     autoIconCheckBox:SetLabel(L["Automatic Icon"])
  102.     autoIconCheckBox:SetValue(objectiveInfo.autoIcon)
  103.     groupScrollFrame:AddChild(autoIconCheckBox)
  104.  
  105.     autoIconCheckBox:SetCallback("OnValueChanged", function(self)
  106.         addon.db.global.objectives[group.objectiveTitle].autoIcon = self:GetValue()
  107.         -- Redraw the group container to display/hide icon editbox and choose button
  108.         addon:DrawObjectiveGroup(group, objectiveTitle)
  109.     end)
  110.  
  111.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  112.     -- iconDisplayEditBox
  113.  
  114.     local iconDisplayEditBox = AceGUI:Create("EditBox")
  115.     iconDisplayEditBox:SetRelativeWidth(1/2)
  116.     iconDisplayEditBox:SetLabel(L["Display Icon"])
  117.     iconDisplayEditBox:SetText(objectiveInfo.icon)
  118.  
  119.     iconDisplayEditBox:SetCallback("OnEnterPressed", function(self)
  120.         addon.db.global.objectives[group.objectiveTitle].icon = self:GetText()
  121.         self:ClearFocus()
  122.     end)
  123.  
  124.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  125.     -- iconChooseButton
  126.  
  127.     local iconChooseButton = AceGUI:Create("Button")
  128.     iconChooseButton:SetRelativeWidth(1/4)
  129.     iconChooseButton:SetText(L["Choose"])
  130.  
  131.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  132.  
  133.     if not objectiveInfo.autoIcon then
  134.         groupScrollFrame:AddChild(iconDisplayEditBox)
  135.         groupScrollFrame:AddChild(iconChooseButton)
  136.     end
  137.  
  138.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  139.     -- buttonsHeading
  140.  
  141.     local buttonsHeading = AceGUI:Create("Heading")
  142.     buttonsHeading:SetFullWidth(true)
  143.     buttonsHeading:SetText(L["Buttons"])
  144.     groupScrollFrame:AddChild(buttonsHeading)
  145.  
  146.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  147.     -- buttonIDEditBox
  148.  
  149.     local buttonIDEditBox = AceGUI:Create("EditBox")
  150.     buttonIDEditBox:SetRelativeWidth(1/2)
  151.     buttonIDEditBox:SetLabel(L["Button ID"])
  152.     groupScrollFrame:AddChild(buttonIDEditBox)
  153.  
  154.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  155.     -- buttonIDChooseButton
  156.  
  157.     local buttonIDChooseButton = AceGUI:Create("Button")
  158.     buttonIDChooseButton:SetRelativeWidth(1/4)
  159.     buttonIDChooseButton:SetText(L["Choose"])
  160.     groupScrollFrame:AddChild(buttonIDChooseButton)
  161.  
  162.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  163.     -- trackersHeading
  164.  
  165.     local trackersHeading = AceGUI:Create("Heading")
  166.     trackersHeading:SetFullWidth(true)
  167.     trackersHeading:SetText(L["Trackers"])
  168.     groupScrollFrame:AddChild(trackersHeading)
  169.  
  170.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  171.     -- trackDropDown
  172.  
  173.     local trackDropDown = AceGUI:Create("Dropdown")
  174.     trackDropDown:SetFullWidth(true)
  175.     trackDropDown:SetLabel(L["Track"])
  176.     trackDropDown:SetList({ALL = L["All"], ANY = L["Any"], CUSTOM = L["Custom"]}, {"ALL", "ANY", "CUSTOM"})
  177.     trackDropDown:SetValue(objectiveInfo.trackType)
  178.     groupScrollFrame:AddChild(trackDropDown)
  179.  
  180.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  181.     -- newTrackerButton
  182.  
  183.     local newTrackerButton = AceGUI:Create("Button")
  184.     newTrackerButton:SetRelativeWidth(1/4)
  185.     newTrackerButton:SetText(L["New Tracker"])
  186.     groupScrollFrame:AddChild(newTrackerButton)
  187.  
  188.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  189.     -- trackerTree
  190.  
  191.     local trackerTreeContainer = AceGUI:Create("SimpleGroup")
  192.     trackerTreeContainer:SetFullWidth(true)
  193.     trackerTreeContainer:SetHeight(400)
  194.     trackerTreeContainer:SetLayout("Fill")
  195.     groupScrollFrame:AddChild(trackerTreeContainer)
  196.  
  197.     local trackerTree = AceGUI:Create("TreeGroup")
  198.     trackerTree:SetLayout("Flow")
  199.     trackerTree:SetTree(addon:GetTrackerTree())
  200.     trackerTreeContainer:AddChild(trackerTree)
  201. end

Picture of solution:

Last edited by Niketa : 10-01-20 at 08:40 AM.
  Reply With Quote