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.