Basic tableview with button embedded, event doesn't trigger on tap

I was making great headway today until I hit a snag. I have an button displayed in my tableview row. 

I will run a function when someone taps this icon.

I can’t seem to get the listener to run. Any ideas as to where I’ve gone wrong.

I’ve scoured the forums, and if I found anything relevant, it looks like mine does :S

Here’s the guts of the tableView, rowRender and load. It won’t run ‘as is’, but you might be able to see where I’ve made a mistake?

 function showclicked(e) -- I only expect to see text printed when I hit the icon. print(e.target.id ) end function onRowTouch(e) print( "Touch" ) -- This does print out end -- Draw the row. local function onRowRender( event ) --Set up the localized variables to be passed via the event table local row = event.row local id = row.index local params = event.row.params -- The row background. row.bg = display.newRect( 0, 0, display.contentWidth, 60 ) row.bg.anchorX = 0 row.bg.anchorY = 0 row.bg:setFillColor( .9, .9, .9 ) row:insert( row.bg ) -- This condition controls what shows where in the row. The text describes which is which element. if ( event.row.params ) then row.fromText = display.newText( "From:"..params.from, 12, 0, native.systemFont, 14 ) row.fromText.anchorX = 0 row.fromText.anchorY = 0.5 row.fromText:setFillColor( 0 ) row.fromText.x = 10 row.fromText.y = 5 -- \>\>\>\> This is the button I can't get a response on. I can see it, but nothing happens. row.icnEdit = widget.newButton{ id = row.index, defaultFile = "assets/icnEdit.png", overFile = "assets/icnEdit.png", width = 20, height = 20, onEvent = showclicked -- What we do when we tap it } row.icnEdit.x = display.contentWidth - 30 row.icnEdit.y = 10 row.icnEdit = display.newImageRect( "assets/icnEdit.png", 20 , 20, 40 ) row.icnEdit.x = display.contentWidth - 30 row.icnEdit.y = 10 row.icnTrash = display.newImageRect( "assets/icnTrash.png", 20 , 20, 40 ) row.icnTrash.x = display.contentWidth - 10 row.icnTrash.y = 30 row.lineSep = display.newImageRect( "assets/lineSep.png", display.contentWidth , 20) row.lineSep.x = display.contentWidth/2 row.lineSep.y = row.height-10 -- Put the rows on the screen in the TableView. row:insert( row.fromText ) row:insert( row.icnEdit ) row:insert( row.icnTrash ) row:insert( row.lineSep ) end return true end -- When we save data via the save button, we want to reload the whole table. We could just add one row, but this is cleaner. -- There won't be a massive amount of data. local function reloadTable() -- flush the table with: myList:deleteAllRows() -- reinsert your data loadTableView() end local function scrollListener( event ) -- return true end -- This will load the table view data in conjunction with row render function loadTableView() locationData = {} -- Clear the location data table so we can reload it. If we don't we will double up. locationData=dbaseLoad.readLocations(locationData) -- Read data from the SQL database. for i = 1, #locationData do -- For every entry in the table, do the following. myList:insertRow{ -- Add teh row with the following properties. rowHeight = 60, isCategory = false, rowColor = { 1, 1, 1 }, lineColor = { 0.90, 0.90, 0.90 }, params = { -- This is where we pass the database data to the row renderer. from = locationData[i].from, to = locationData[i].to, distance = locationData[i].distance, purpose = locationData[i].purpose } } sceneGroup:insert(myList) -- Add the tableview to the scene group end end -- Draw the tableView widget - all teh above leads from here :) local navBarHeight = 60 local tabBarHeight = 50 myList = widget.newTableView { top = 200, width = display.contentWidth, height = display.actualContentHeight - 240, onRowRender = onRowRender, onRowTouch = onRowTouch, listener = scrollListener -- I'm not using this listener right now. } loadTableView() -- This runs the above function that loads data to the tableview we just created. It's a function so we can reload it later when we add stuff

OK, it was a daft mistake, it only took me 5 hours to locate it :S

Here’s the mistake… (Marked with *****)

– >>>> This is the button I can’t get a response on. I can see it, but nothing happens. row.icnEdit = widget.newButton{ id = row.index, defaultFile = “assets/icnEdit.png”, overFile = “assets/icnEdit.png”, width = 20, height = 20, onEvent = showclicked – What we do when we tap it } row.icnEdit.x = display.contentWidth - 30 row.icnEdit.y = 10 ***** row.icnEdit = display.newImageRect( “assets/icnEdit.png”, 20 , 20, 40 ) ***** row.icnEdit.x = display.contentWidth - 30 ***** row.icnEdit.y = 10 row.icnTrash = display.newImageRect( “assets/icnTrash.png”, 20 , 20, 40 ) row.icnTrash.x = display.contentWidth - 10 row.icnTrash.y = 30

I basically drew the icon over the top if it again. I remove these 3 lines and voila.

Sigh

Have a good day/night!

OK, it was a daft mistake, it only took me 5 hours to locate it :S

Here’s the mistake… (Marked with *****)

– >>>> This is the button I can’t get a response on. I can see it, but nothing happens. row.icnEdit = widget.newButton{ id = row.index, defaultFile = “assets/icnEdit.png”, overFile = “assets/icnEdit.png”, width = 20, height = 20, onEvent = showclicked – What we do when we tap it } row.icnEdit.x = display.contentWidth - 30 row.icnEdit.y = 10 ***** row.icnEdit = display.newImageRect( “assets/icnEdit.png”, 20 , 20, 40 ) ***** row.icnEdit.x = display.contentWidth - 30 ***** row.icnEdit.y = 10 row.icnTrash = display.newImageRect( “assets/icnTrash.png”, 20 , 20, 40 ) row.icnTrash.x = display.contentWidth - 10 row.icnTrash.y = 30

I basically drew the icon over the top if it again. I remove these 3 lines and voila.

Sigh

Have a good day/night!