Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-21-24, 01:11 PM   #1
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
Post Button not showing on frame

I'm a beginner when it comes to addon development...
I created a simple addon with a frame and a button but the button is not showing up on the frame.
I've looked at a few other examples but can't see what I'm doing wrong.
I have bug sack/bug grabber enabled and not seeing any errors.
Any help is much appreciated.

Here is my lua file.

Lua Code:
  1. -- Load the AceGUI and LibDBIcon libraries
  2. local AceGUI = LibStub("AceGUI-3.0")
  3. local LibDBIcon = LibStub("LibDBIcon-1.0")
  4.  
  5. -- Create a new frame
  6. local frame = AceGUI:Create("Frame")
  7. frame:SetTitle("MyAddon Frame")
  8. frame:SetStatusText("Example Status Text")
  9. frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
  10. frame:SetLayout("Flow")
  11. frame:Hide()
  12.  
  13. -- Create a button
  14. local button = AceGUI:Create("Button")
  15. button:SetText("Click Me!")
  16. button:SetWidth(200)
  17. button:SetCallback("OnClick", function() print("Button Clicked!") end)
  18.  
  19. -- Add the button to the frame
  20. frame:AddChild(button)
  21.  
  22. -- Create a minimap button
  23. local showFrame = false
  24. local icon = LibDBIcon:Register("MyAddon", {
  25.     icon = "Interface\\Icons\\Ability_Marksmanship",
  26.     OnClick = function(self, button)
  27.         if button == "LeftButton" then
  28.             frame:Show()
  29.         elseif button == "RightButton" then
  30.             frame:Hide()
  31.         end
  32.     end,
  33.     OnTooltipShow = function(tooltip)
  34.         tooltip:SetText("MyAddon")
  35.         tooltip:AddLine("Left-click to open", 1, 1, 1)
  36.         tooltip:AddLine("Right-click to close", 1, 1, 1)
  37.     end,
  38. })
  39.  
  40. -- Register the addon
  41. local addonName, addonTable = ...
  42. addonTable.frame = frame

Last edited by Codger : 03-23-24 at 02:29 PM. Reason: Add lua syntax highlighting
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Button not showing on 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