
I have a grid of numbers like yous see above. I would like the user to eb able to drag their finger across the array of buttons and select multiple numbers. For example if I dragged my finger across the top row of buttonsI would have selected “5,2,9,4,7,0”. I would then like to add these number to a lua table for later use.
I am using the widget.newButton fucntion to make the buttons but I can’t get the event handling to work as I need. This is my code so far:
local widget = require( "widget" ) local function handleButtonEvent( event ) local phase = event.phase local target = event.target if "began" == phase then -- not sure what to do here end end function createTiles(numTiles, padding) local tileDimension = (display.contentWidth / numTiles) - padding local x = padding/2 local y = display.contentHeight - numTiles \* (tileDimension + padding) -- Create an array of tiles for i = 1, numTiles, 1 do for j = 1, numTiles, 1 do local value = math.random(0,9) local myButton = widget.newButton { left = x, top = y, width = tileDimension, height = tileDimension, id = value..i..j, label = value, onEvent = handleButtonEvent, } x = x + tileDimension + padding end x = padding/2 y = y + tileDimension + padding end end local function addToNumSelect (num) end numselect = {} createTiles(6,1)
I woudl really appreciate some help on this!