1. I've hit a block. Let me explain what I have and what I'm trying to do:

    I created a panel that when clicked, opens another panel with 6 Buttons on it. Five of these Buttons place World Markers, and the last Button clears them. The code for these buttons in the OnLoad in kgPanels is as follows:

     self.action = CreateFrame("Button",nil,self,"SecureActionButtonTemplate")
     self.action:SetAttribute("macrotext","/wm #")
     self.action.parent = self
     self.action:SetScript("PostClick",function(self,...) local
     f=self.parent:GetScript("OnClick") if f then f(self.parent,...) end end)

    Where #=(1,2,3,4,5)

    Everything works exactly as intended except one thing which i'm not sure how to program. When a world Marker button is pressed, not only do i want to be able to place the world marker, but i want it to close the frame with all of the World Marker buttons on it. I've tried (without success) giving the square (or triangle, star, etc.) marker button the OnClick command:

     if pressed then
      if kgPanels:FetchFrame("World Marker - Panel"):IsShown() then
       kgPanels:FetchFrame("World Marker - Panel"):Hide()
       kgPanels:FetchFrame("World Marker - Panel"):Show()
     elseif released then

    "World Marker - Panel" is the name of the panel that pops up with all six buttons on when the initial panel is clicked. This last little road block is the only thing between me and a complete UI. Any help would be greatly appreciated. Thanks a lot.

    You're going to have to give the SecureActionButton a PostClick (or PreClick) script that hides all the buttons again. Be aware that all of this stuff won't work in combat though (you can't hide/show secure templates in combat).

    Thanks for the response. Two questions though -

    1. Is there a way to make it work in combat? I'm alright with it not working in combat but it would be great if it did.

    2. I'm an extreme novice when it comes to programming. Can you tell me how to program a PostClick function to close the buttons?


    If you want to make it work in combat, use :SetAlpha(0) and :SetAlpha(1) instead of :Hide() and :Show(), respectively. Note, however, that this will merely make the buttons invisible, but not unclickable.

    As for the closing script, you can probably use the following:

    local action_postClick = function(self) self:GetParent():Hide() end

    And then for every button you do:


    Replace :Hide() with :SetAlpha(0) if you want to make it work in combat, as I said earlier.

    PS: If you don't go with the SetAlpha approach, I'd highly recommend giving your main panel an OnEvent script for PLAYER_REGEN_DISABLED that does self:Hide() - that way the panels won't be stuck in a shown state when you enter combat

    EDIT: Looking at your code, I just noticed that you appear have one kgPanel for each of the buttons (as you use self.action, not self[("action%d"):format(i)] or equivalent for a loop). Is that correct? If so, why don't you make a single panel with all the buttons inside it? That's what I assumed writing the post above. Your PostClick will get a lot more complicated if you have multiple panels (add a FetchFrame for each of the other 4 panels, then hide them, too).

    I really appreciate your responses. I'm not sure that you understand how much of a programming novice i am though.... =P 90% of the code i have posted i was able to find on the internet. So when you are talking about self.actions and loops and making all the buttons on one panel i have no idea how to do that. I decided not to go with the SetAlpha option because that wouldn't work well with the layout of my UI. If you could explain how to put all the buttons on one panel and loops and all that, I would greatly appreciate it. Again, what i have are six buttons that i have resized and moved on to one panel that opens and closes with the push of another button on my UI. So essentially that first button, which is places at the bottom of my screen, opens a total of seven panels; the world marker panel, with six world marker buttons parented to it. Thanks again for all your help. I hope i can get this fixed soon.

    Well, your OnLoad would probably look something like this:

    local btnWidth = 30 -- the width of each button
    local btnHeight = 30 -- the height of each button
    local leftBorderOffset = 15 -- from the left border of the kgPanel to the first button
    local btnOffset = 10 -- pixels between the buttons
    self.buttons = {}
    local hideFunc = function(s) s.parent:Hide() end
    for n=1,6 do
        local btn = CreateFrame("Button",nil,self,"SecureActionButtonTemplate")
        btn:SetSize(width,height) -- replace this
        btn:SetPoint("LEFT",leftBorderOffset + ((n-1) * (btnWidth + btnOffset)),0)
        btn.parent = self
        if n == 6 then
            btn:SetAttribute("macrotext",("/wm %d"):format(n))
        self.buttons[n] = btn

    Panel width should be set to (2*leftBorderOffset + 5*btnOffset + 6*btnWidth). In the script for the open/close button, you'd simply :Show() this one button panel.

    That about 90% worked. It created a panel but shows only one button. Also, I'm confused because at the top of the code you have written in local btnWidth = * and local btnHeight = *, and then just below that in the next block of code it says btn:SetSize(,). Only changing the btn:SetSize variables changes the size of the buttons. The four variables, "local btnWidth", "local btnHeight", "local leftBorderOffset", and "local btnOffset" don't seem to do anything. The button is right up against the left edge of the panel which is what leads me to believe that "local leftBorderOffset" isn't doing anything.

    Again, thanks so much for the help. The button that does show up is functioning exactly like i want it to. I'm really close to having this done now.

    Thanks a bunch.

    I kinda typed that post up, then had to leave and only skimmed over it before posting. You're right, that should be :SetSize(btnWidth, btnHeight), and there's also some other stuff I forgot to remove. I edited the post above, try it out now. Make sure you change the six calls to :SetNormalTexture() to point to the flares' respective textures!

    Well it is now resizing as intended via code at top, however it still seems as though the buttons are stacking on top of each other and the left border of the button is still right up against the edge of the frame and not 15 pixels offset like intended. Also, something else i noticed that was acting strange, each time i /reload the icon changes but it still does the correct action when clicked, which would be /wm 1 as would be expected of the first button if it were on top of the suspected stack. Any ideas? So close! Also, i'm curious what the "%d" does.

    Fixed above again, I forgot to provide 0 as the third argument to :SetPoint().

    PS: ("/wm %d"):format(n) is the same as string.format("/wm %d",n). The return value will be the same as "/wm "..n, except that I believe string.format to be more efficient than .. concatenation for numbers.

    You rock! That was it. I've got a couple other things i want to mess with and then it'll be done. I want to figure how to do it on my own though. If it turns out i need help i'll post again. Thanks so much for all the help!

    Glad I could be of help.