Button and List View events (example inside)

Hello All,

I’m looking for a solution for events listener when a button (or any other event listener) is over a list view.
Listview events always return first… and don’t allow others events to be returned…

Here’s an example :
When you scroll up the list and you try to press the button, you can see that only the “press phase” is returned by the button

[lua]local ui = require(“ui”)
local tableView = require(“tableView”)
– Create a main group & header
local headerGroup = display.newGroup()
local mainGroup = display.newGroup()
– Add random data
local someData = {}
for i=1, 10 do

someData[i] = {}
someData[i].id = i
someData[i].title = "List item " … i
someData[i].subtitle = "Subtitle " … i
end
– Create a list
local function loadItem(event)
if event.phase == “ended” then
print( event.target.id )
end
end
local myList = tableView.newList{
data=someData,
default=“listItemBg.png”,
over=“listItemBg_over.png”,
onRelease=loadItem,
backgroundColor={255,255,255},
top=80,
bottom=0,
callback=function(data)
local t = display.newGroup()
local t1 = display.newText( data.title, 0, 0, native.systemFontBold,20)
t1:setTextColor(30,30,30)
t1.x = math.floor(t1.width/2) + 20
t1.y = 30
local t2 = display.newText(data.title, 0, 0, native.systemFont,16 )
t2:setTextColor(60,60,60)
t2.x = math.floor(t2.width/2) + 20
t2.y = 50

t:insert(t1)
t:insert(t2)
return t
end
}

mainGroup:insert(myList)

– Let’s build a “header”
local backgroundHeader = display.newRect(0,0,320,80)
backgroundHeader:setFillColor(0, 0, 120,190)
headerGroup:insert(backgroundHeader)

– event listener for a button
local function buttonListener (event)

print( event.phase )

end

local button = ui.newButton{ default=“backButton.png”, over=“backButton_over.png”, id=1, onEvent=buttonListener }
button.x = 40
button.y = 40
headerGroup:insert(button)

– adding the header to the main group
mainGroup:insert(headerGroup)[/lua] [import]uid: 3638 topic_id: 6653 reply_id: 306653[/import]

OK i found the answer in this very forum http://developer.anscamobile.com/forum/2010/09/02/layersgroups-events-behavior

[lua]-- event listener for a button
local function buttonListener (event)

print( event.phase )
– must add "return true in order to work
return true
end[/lua] [import]uid: 3638 topic_id: 6653 reply_id: 23245[/import]