How can I create a template buttom? - WoWInterface
Thread Tools Display Modes
01-02-06, 10:08 PM   #1
A Defias Bandit
Join Date: Jan 2006
Posts: 2
How can I create a template button?

How can I create a template button?

Last edited by Tealy : 01-03-06 at 04:18 PM.
  Reply With Quote
01-03-06, 09:15 AM   #2
A Firelord
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 491
To make a button a template add a virtual="true" in the opening tag:

<Button name="MyButtonTemplate" virtual="true">

To use: <Button name="MyButton1" inherits="MyButtonTemplate"/>

For instance this is a button template that's 96x32 with an OnEnter, OnLeave and OnClick.

<Button name="MyButtonTemplate" inherits="UIPanelButtonTemplate" virtual="true">
<AbsDimension x="96" y="32"/>
MyMod_MyButton_OnTooltip() -- display tooltip for this button

Then you can reuse that template to lay out buttons without declaring all the rest:

<Button name="MyButton1" inherits="MyButtonTemplate" text="One" id="1">
<Anchor point="TOPLEFT"/>
<Button name="MyButton2" inherits="MyButtonTemplate" text="Two" id="2">
<Anchor point="TOP"/>
<Button name="MyButton3" inherits="MyButtonTemplate" text="Three" id="3">
<Anchor point="TOPRIGHT"/>

In the MyMod_MyButton_OnClick() to determine which button was pressed you use 'this' which is always the frame that calls an event handler:

this:GetID() = 1, 2 or 3 (due to the id="1" to id="3" tags)
this:GetName() = "MyButton1", "MyButton2", "MyButton3" (from the name= tags)
this = MyButton1, MyButton2, MyButton3 (the frame itself)
  Reply With Quote
01-03-06, 04:13 PM   #3
A Defias Bandit
Join Date: Jan 2006
Posts: 2
Thank you so much..
Is there any way to create a template button with WoW UI Designer?
  Reply With Quote
01-03-06, 10:39 PM   #4
A Cobalt Mageweaver
Nulkris's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 214
You need to create a skin in which you can define new button templates to place onto forms.

See http://www.wowinterface.com/forums/s...ead.php?t=2018 to get started.
Nulkris - A80 Rogue - Proudmoore
(Also Drukris, Hamkris on Proudmoore; Hulkris on Jubei'Thos & Khaz Modan)
  Reply With Quote
12-15-06, 04:00 AM   #5
A Defias Bandit
Join Date: Dec 2006
Posts: 2
Maybe just a stupid question: Can I create templates for sliders in the same way? I tried it for my own addon but it won't work as expected, so I'm a bit confused...
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How can I create a template buttom?

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