How can register multiple button presses from a single drag event?

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!

Someone wanted to do a similar thing a few days ago, my suggestion in that post should work for you too:

http://forums.coronalabs.com/topic/39274-ruzzle-clone-is-it-possible-with-corona-sdk/

Thanks very much for this code. This should work and I am going to have a go at implementing it tomorrow. I have some questions but I am will reply into the original thread!

Someone wanted to do a similar thing a few days ago, my suggestion in that post should work for you too:

http://forums.coronalabs.com/topic/39274-ruzzle-clone-is-it-possible-with-corona-sdk/

Thanks very much for this code. This should work and I am going to have a go at implementing it tomorrow. I have some questions but I am will reply into the original thread!