WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   How can I create a template buttom? (https://www.wowinterface.com/forums/showthread.php?t=2777)

Tealy 01-02-06 10:08 PM

How can I create a template button?
 
How can I create a template button? ;)

Gello 01-03-06 09:15 AM

To make a button a template add a virtual="true" in the opening tag:

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

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">
<Size>
<AbsDimension x="96" y="32"/>
</Size>
<Scripts>
<OnEnter>
MyMod_MyButton_OnTooltip() -- display tooltip for this button
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
<OnClick>
MyMod_MyButton_OnClick()
</OnClick>
</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">
<Anchors>
<Anchor point="TOPLEFT"/>
</Anchors>
</Button>
<Button name="MyButton2" inherits="MyButtonTemplate" text="Two" id="2">
<Anchors>
<Anchor point="TOP"/>
</Anchors>
</Button>
<Button name="MyButton3" inherits="MyButtonTemplate" text="Three" id="3">
<Anchors>
<Anchor point="TOPRIGHT"/>
</Anchors>
</Button>

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)

Tealy 01-03-06 04:13 PM

Thank you so much..
Is there any way to create a template button with WoW UI Designer?

Nulkris 01-03-06 10:39 PM

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.

Suppi 12-15-06 04:00 AM

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...


All times are GMT -6. The time now is 11:47 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI