Thanks for the help. Moving the :hide call fixed the button issue.
I also commented out the line:
--frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
and now the button shows up with when the frame is opened and closed which makes me wonder when I should be concerned about release the widgets? Do most addons leave the frame open?
Lua Code:
-- Load the AceGUI and LibDBIcon libraries
local AceGUI = LibStub("AceGUI-3.0")
local LibDBIcon = LibStub("LibDBIcon-1.0")
-- Create a new frame
local frame = AceGUI:Create("Frame")
frame:SetTitle("MyAddon Frame")
frame:SetStatusText("Example Status Text")
--frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
frame:SetLayout("Flow")
-- Create a button
local button = AceGUI:Create("Button")
button:SetText("Click Me!")
button:SetWidth(200)
button:SetCallback("OnClick", function() print("Button Clicked!") end)
-- Add the button to the frame
frame:AddChild(button)
--frame:Hide()
-- Create a minimap button
local showFrame = false
local icon = LibDBIcon:Register("MyAddon", {
icon = "Interface\\Icons\\Ability_Marksmanship",
OnClick = function(self, button)
if button == "LeftButton" then
frame:Show()
elseif button == "RightButton" then
frame:Hide()
end
end,
OnTooltipShow = function(tooltip)
tooltip:SetText("MyAddon")
tooltip:AddLine("Left-click to open", 1, 1, 1)
tooltip:AddLine("Right-click to close", 1, 1, 1)
end,
})
-- Register the addon
local addonName, addonTable = ...
addonTable.frame = frame