I am trying to link my button (widget) to a function. I have very limited knowledge on functions so far and I wanted to start off with the one from the API, but it won’t work.
This is what I have:
local widget = require("widget") -- Create Button local button1 = widget.newButton( { label = "START", font = "BebasNeue.otf", fontSize = 50, labelYOffset = 2, labelColor = { default={0, 0, 0, 0.5 }, over={0, 0, 0, 0.5} }, -- Properties for a rounded rectangle button shape = "roundedRect", width = 200, height = 80, cornerRadius = 10, fillColor = { default={146/255,205/255,0,0.5}, over={146/255,205/255,0,0.4} }, strokeColor = { default={1, 1, 1}, over={1, 1, 1, 0.75} }, strokeWidth = 8, onEvent = handleButtonEvent } ) -- Center the button button1.x = display.contentCenterX button1.y = display.contentCenterY --------------- -- Functions -- --------------- local function handleButtonEvent( event ) if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end