如何识别电晕sdk表中触摸的对象?

时间:2016-04-29 12:11:05

标签: lua corona

说我在日冕有一个表格视图,其中有一个单元格,这三个对象具有不同的ID,我可以识别行触摸,但是如何识别表格视图中触摸的对象?

enter image description here

这是我正在使用的代码

// write anywhere in your javaScript code
JSInterface.showToast("Show Toast");

local function onRowRender( event )
  local row = event.row
  local rowHeight = row.contentHeight
  local rowWidth = row.contentWidth

  local speaker1 = display.newImage(row,"images/listen.png",70,70)
  speaker1.width = 20;speaker1.height = 20*ryx
  speaker1.x = 35;speaker1.y = suby
  speaker1.id = "speaker1"

  local eye1 = display.newImage(row,"images/eye.png",70,70)
  eye1.width = 20;eye1.height = 20*ryx
  eye1.x = 60;eye1.y = suby
  eye1.id = "eye1"

  speaker1:addEventListener("touch",onObjectTouch)
  eye1:addEventListener("touch",onObjectTouch)

end

我尝试为每个对象使用触控侦听器,没有运气

1 个答案:

答案 0 :(得分:1)

 speaker1:addEventListener("touch",onObjectTouch)
  eye1:addEventListener("touch",onObjectTouch)

您可以在此处添加EventListener onObjectTouch,但您已实施onRowTouch

您应该实现onObjectTouch或重命名添加的EventListener。