1. Hi All,

    I just started programming my first addon and I am still learning the ropes, I have a pretty solid programming background however. I have a snip-it of code that is supposed to create a blue box with up to 9 sub frames inside arranged in a square formation. Everything was working fine until I added the on mouse down function. Now the 9 subframes are not visible, but the on click function works perfectly. I tried reverting my changes and still could not get the subframes to reappear. What am I missing?

     SLASH_DRAWBOXES1 = "/db"
     local MultiDotsMainFrameX =1000
     local MultiDotsMainFrameY=300
     local MultiDotsMainFrameWidth=300
     local MultiDotsMainFrameHeight=300
     local maxNumberOfBoxes=9
     local subFrames=CreateFrame("Frame","subFrames",MultiDotsMainFrame)
    
     local function hideAllSubFrames()
        for i = 1, maxNumberOfBoxes do
            if subFrames[i] then
                subFrames[i]:Hide()
            end
        end
     end
    
     local function helloWorld(self, button)
        print("Hello World")
     end
    
     local function drawMultiDotsMainFrame()
        MultiDotsMainFrame=CreateFrame("Frame", "MultiDotsMainFrame", UIParent)
        MultiDotsMainFrame:SetSize(MultiDotsMainFrameWidth,MultiDotsMainFrameHeight)
        MultiDotsMainFrame:SetPoint("TOPLEFT",MultiDotsMainFrameX,-MultiDotsMainFrameY)
        MultiDotsMainFrame.backGround=MultiDotsMainFrame:CreateTexture("MultiDotsMainFrame_backGround","BACKGROUND")
        MultiDotsMainFrame.backGround:SetSize(MultiDotsMainFrameWidth,MultiDotsMainFrameHeight)
        MultiDotsMainFrame.backGround:SetPoint("CENTER")
        MultiDotsMainFrame.backGround:SetTexture(0,0,1,.1)
        MultiDotsMainFrame.title = MultiDotsMainFrame:CreateFontString(MultiDotsMainFrame_Title, "OVERLAY", "GameFontNormal")
        MultiDotsMainFrame.title:SetPoint("TOP", 0, 18)
        MultiDotsMainFrame.title:SetText("MultiDotsMainFrame")
     end
    
     local function drawBoxesInMain(numberOfBoxes)
        local boxesPerRow= math.ceil(numberOfBoxes^(.5))
        local cntr=0
        local spacer=3
        local subFrameWidth=math.floor(MultiDotsMainFrameWidth/boxesPerRow)-(spacer/2)*boxesPerRow
        local subFrameHeight=math.floor(MultiDotsMainFrameHeight/boxesPerRow)-(spacer/2)*boxesPerRow
        hideAllSubFrames()
        for i = 1, boxesPerRow do
            for j= 1, boxesPerRow do
                if cntr<numberOfBoxes then
                    cntr=cntr+1
                    if not subFrames[cntr] then
                        subFrames[cntr]=CreateFrame("Frame","subFrames"..cntr,MultiDotsMainFrame)
                        subFrames[cntr].backGround=subFrames[cntr]:CreateTexture("subFrames"..cntr.."_backGround","BACKGROUND")
                    end
                    subFrames[cntr].backGround:SetTexture(.1,.1,.1,.5)
                    subFrames[cntr]:SetSize(subFrameWidth,subFrameHeight)
                    subFrames[cntr].backGround:SetSize(subFrameWidth,subFrameHeight)
                    if cntr==1 then
                        subFrames[cntr]:SetPoint("TOPLEFT",spacer,-spacer)
                    elseif j==1 then
                        subFrames[cntr]:SetPoint("TOPLEFT",subFrames[cntr-boxesPerRow],"BOTTOMLEFT",0,-spacer)
                    else
                        subFrames[cntr]:SetPoint("TOPLEFT",subFrames[cntr-1],"TOPRIGHT",spacer,0)
                    end
                    subFrames[cntr]:SetScript("OnMouseDown",helloWorld)
    
                end
            end
        end
     end
    
     local function innitalizeMultiDots()
        drawMultiDotsMainFrame()
     end
     SlashCmdList["DRAWBOXES"] = function(numberOfBoxes)
        drawBoxesInMain(tonumber(numberOfBoxes))
     end
    
    
    
     innitalizeMultiDots()
     drawBoxesInMain(2)
    

    The order in which you are doing things matter. You are creating the subFrame before you've ever created the multiframe. I'd go back and make sure things are being done in precisely the order you expect them to, as I think that will have something to do with your issue.

    I moved the subFrame and it had no effect. That makes alot of sense but I am not sure why I did not work. I also tried changing the subFrame's parent to be UIParent to see if i could get them to appear at all, but that did not work either. Additionally, when I added a conditional to print if the subframe were shown and visible it printed for each subframe.

     SLASH_DRAWBOXES1 = "/db"
     local MultiDotsMainFrameX =1000
     local MultiDotsMainFrameY=300
     local MultiDotsMainFrameWidth=300
     local MultiDotsMainFrameHeight=300
     local maxNumberOfBoxes=9
    
     local function hideAllSubFrames()
        for i = 1, maxNumberOfBoxes do
            if subFrames[i] then
                subFrames[i]:Hide()
            end
        end
     end
    
     local function helloWorld(self, button)
        print("Hello World")
     end
    
     local function drawMultiDotsMainFrame()
        MultiDotsMainFrame=CreateFrame("Frame", "MultiDotsMainFrame", UIParent)
        MultiDotsMainFrame:SetSize(MultiDotsMainFrameWidth,MultiDotsMainFrameHeight)
        MultiDotsMainFrame:SetPoint("TOPLEFT",MultiDotsMainFrameX,-MultiDotsMainFrameY)
        MultiDotsMainFrame.backGround=MultiDotsMainFrame:CreateTexture("MultiDotsMainFrame_backGround","BACKGROUND")
        MultiDotsMainFrame.backGround:SetSize(MultiDotsMainFrameWidth,MultiDotsMainFrameHeight)
        MultiDotsMainFrame.backGround:SetPoint("CENTER")
        MultiDotsMainFrame.backGround:SetTexture(0,0,1,.1)
        MultiDotsMainFrame.title = MultiDotsMainFrame:CreateFontString(MultiDotsMainFrame_Title, "OVERLAY", "GameFontNormal")
        MultiDotsMainFrame.title:SetPoint("TOP", 0, 18)
        MultiDotsMainFrame.title:SetText("MultiDotsMainFrame")
     end
    
    
     local function drawBoxesInMain(numberOfBoxes)
    
        local boxesPerRow= math.ceil(numberOfBoxes^(.5))
        local cntr=0
        local spacer=3
        local subFrameWidth=math.floor(MultiDotsMainFrameWidth/boxesPerRow)-(spacer/2)*boxesPerRow
        local subFrameHeight=math.floor(MultiDotsMainFrameHeight/boxesPerRow)-(spacer/2)*boxesPerRow
        hideAllSubFrames()
        for i = 1, boxesPerRow do
            for j= 1, boxesPerRow do
                if cntr<numberOfBoxes then
                    cntr=cntr+1
                    if not subFrames[cntr] then
                        subFrames[cntr]=CreateFrame("Frame","subFrames"..cntr,MultiDotsMainFrame)
                        subFrames[cntr].backGround=subFrames[cntr]:CreateTexture("subFrames"..cntr.."_backGround","BACKGROUND")
                    end
                    subFrames[cntr].backGround:SetTexture(.1,.1,.1,.5)
                    subFrames[cntr]:SetSize(subFrameWidth,subFrameHeight)
                    subFrames[cntr].backGround:SetSize(subFrameWidth,subFrameHeight)
                    if cntr==1 then
                        subFrames[cntr]:SetPoint("TOPLEFT",spacer,-spacer)
                    elseif j==1 then
                        subFrames[cntr]:SetPoint("TOPLEFT",subFrames[cntr-boxesPerRow],"BOTTOMLEFT",0,-spacer)
                    else
                        subFrames[cntr]:SetPoint("TOPLEFT",subFrames[cntr-1],"TOPRIGHT",spacer,0)
                    end
                    subFrames[cntr]:SetScript("OnMouseDown",helloWorld)
                    if subFrames[cntr]:IsVisible() then
                        if subFrames[cntr]:IsShown() then
                            print (cntr)
                        end
                    end
    
                end
            end
        end
     end
    
     local function innitalizeMultiDots()
        drawMultiDotsMainFrame()
     end
     SlashCmdList["DRAWBOXES"] = function(numberOfBoxes)
        drawBoxesInMain(tonumber(numberOfBoxes))
     end
    
    
    
     innitalizeMultiDots()
     local subFrames=CreateFrame("Frame","subFrames",MultiDotsMainFrame)
     drawBoxesInMain(2)
    

    I don't have any massively brilliant ideas off the top of my head. I would suggest just working through this bit by bit using something like WoWLua and making sure each step works before you've moved on to the next one. I don't see anything immediately wrong, but it's a lot of code to just glance at =)

    The whole point of this forum is so that you can get help and then later, if someone else has the same issue, they can be helped as well. Replacing your original question and/or code with "solved" isn't helping anyone.

    Yeah I really REALLY don't understand people who do that. Reverted =)