I created a module
custombutton.lua
local CustomButton = {}
local CustomButton_mt = { __ index = CustomButton}
local widget = require(“widget”)
function CustomButton.New(eventHandler)
local newCustomButton = widget.newButton {
label=“abc”,
labelColor= { default={255}, over={128}},
defaultFile=“test.png”,
width=100, height = 100,
x = display.contentCenterX,
y = display.contentCenterY,
onEvent = eventHandler
}
return setmetatable(newCustomButton, CustomButton_mt)
end
main.lua
local customButtonModule = require(“custombutton”)
local function onButtonClick(event)
print(“test”)
end
local button1 = customButtonModule.New(onButtonClick)
So button was created but whenever my mouse was over it, it throw an error saying
“attempt to call a nil value”
Any idea what I did wrong in the module?
