Thread Tools Display Modes
01-20-17, 07:50 PM   #1
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Add button inside interface panel

Hello!

I am working on a project for my guild regarding an assist addon!
I have created a panel inside "interface -> Addons , called myAddon" so interface -> addons -> myAddon
Current code for the panel
Lua Code:
  1. myAddon = {};
  2. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  3. myAddon.panel.name = "HelyaAssist";
  4. InterfaceOptions_AddCategory(myAddon.panel);

I cant rap my head around how to make a button inside that panel. I already have the code for the button. But i do not know how i can make a button that would be inside that panel i have created!
I want to make a enable and disable button for my assist addon.

Current code for the button , this code will just make a button right on the center of the screen (not in the panel). But how can i make it go inside the panel on interface -> addons -> myAddon
Lua Code:
  1. --Create the button (enable)
  2. mybutton1 = CreateFrame("Button","mybutton", UIParent, "UIPanelButtonTemplate")
  3. mybutton1:SetPoint("CENTER",0,0)
  4. mybutton1:SetWidth(80)
  5. mybutton1:SetHeight(22)
  6. mybutton1:SetText("Enabled")

Best regards!
  Reply With Quote
01-20-17, 08:17 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Naming your addon table "myAddon" and leaving it as a declared global is a very, very bad idea. Put the word "local" in front of that declaration.

Anyway, have a read here: http://wow.gamepedia.com/Using_the_I...s_Addons_panel
  Reply With Quote
01-21-17, 05:28 AM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
It's very simple!

The UIParent here specifies the parent of the button. Just change it to your frame.
Lua Code:
  1. mybutton1 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Add button inside interface panel

Thread Tools
Display Modes

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