Originally Posted by Zaxer
Code:
function Frame1.Load
this:RegisterEvent("AddFriend")
function Button1_OnClick()
this:AddFriend("Zaxer")
end
|
I'm not sure what the rest of the code looks like, but you didn't end the first function for starters. Also, from the error there, it looks like your Button1 doesn't exist yet, so you can't make an OnClick() function for it unless it exists.
Here's some simple code that makes a box on the screen that you can click. You'll have to define what it will do, though. Right now, all it will do is put some text in your chat box to know it is working.
MyAddon.toc:
Code:
## Interface: 30100
## Author: recluse
## Title: MyAddon
MyAddon.lua
MyAddon.lua:
Code:
MyAddon = {}
function MyAddon:AddFriend(name)
DEFAULT_CHAT_FRAME:AddMessage("Called AddFriend() with tne name "..name)
end
local function Button1_OnClick(button, click)
MyAddon:AddFriend("Zaxer")
end
do
MyAddon.Frame1 = CreateFrame("Frame", nil, UIParent)
MyAddon.Frame1:SetHeight(100); MyAddon.Frame1:SetWidth(100)
MyAddon.Frame1:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
MyAddon.Frame1:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
edgeFile = nil, edgeSize = 0,
insets = {left = 0, right = 0, top = 0, bottom = 0},
})
MyAddon.Button1 = CreateFrame("Button", nil, MyAddon.Frame1)
MyAddon.Button1:SetAllPoints(MyAddon.Frame1)
MyAddon.Button1:RegisterForClicks("AnyUp")
MyAddon.Button1:SetScript("OnClick", Button1_OnClick)
MyAddon.Button1:Show()
MyAddon.Frame1:Show()
end