View Single Post
03-01-23, 09:46 AM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Frame custom function

I created a template like this

Code:
<Frame name="My_GroupBox" toplevel="true" virtual="true">
		<Backdrop bgFile="Interface\ChatFrame\ChatFrameBackground" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
			<BackgroundInsets>
				<AbsInset left="3" right="3" top="5" bottom="3" />
			</BackgroundInsets>
			<TileSize>
				<AbsValue val="16" />
			</TileSize>
			<EdgeSize>
				<AbsValue val="16" />
			</EdgeSize>
			<Color r="0.1" g="0.1" b="0.1" a="0.5"/>
			<BorderColor r="0.4" g="0.4" b="0.4"/>
		</Backdrop>
		<Layers>
			<Layer level="OVERLAY">
				<FontString parentKey="label" inherits="GameFontNormal" text="" justifyH="LEFT">
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
							<Offset>
								<AbsDimension x="10" y="15"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
	</Frame>
Is it possible to assign functions to this template in this form?

Lua Code:
  1. My_GroupBox:myfunction(
  2.     -- do stuffs
  3. )

EDIT: Maybe this can be a solution?

Lua Code:
  1. local mt = {
  2.     myfunction = function(self)
  3.         -- do stuffs
  4.     end
  5. }
  6.  
  7. setmetatable(My_GroupBox, { __index = setmetatable(mt, getmetatable(My_GroupBox)) })

Last edited by Benalish : 03-01-23 at 10:01 AM.
  Reply With Quote