Thread Tools Display Modes
01-22-10, 03:20 PM   #1
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Object commands and templates

Greetings. I've started to rely more heavily on templates when creating the UI, and have been trying to find the best way, if it's possible, to create commands for XML object templates without having to use up the OnLoad handle. For example, say I want to create a checkbutton template that includes SetText and GetText. I would create the code as follows:

Code:
<CheckButton name="MyTemplate" inherits="OptionsCheckButtonTemplate" virtual="true"
  <Size>...</Size>
  <Anchors>...</Anchors>
  <Scripts>
    <OnLoad>
      function self:SetText(text)
        _G[self.GetName().."Text"]:SetText(text)
      end
      function self:GetText(text)
        return  _G[self.GetName().."Text"]:GetText()
      end
    </OnLoad>
  </Scripts>
</CheckButton>
The code works fine. However, if a create a CheckButton with this template I can no longer use the OnLoad without using code heavy work arounds such as events or code scripting.

I'm hoping someone knows of an easy way to do this, that I am just unaware of.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Object commands and templates


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