here is recoring on iOS Simulator and console output
http://www.youtube.com/watch?v=o2zjfJfCFTw&
If I drag across the table and release while on last cell I get the “touch ended” event phase. However if I drag across cells and release the mouse when I’m outside of cells only “touch started” phase will be reported while “touch ended” pahse will not be reported even though mouse has been released? This is happening both on Corona Simulator, iOS Simulator and on device.
How do I get touch ended phase if I go outside of table and the lift the finger? Application will not get the last event phase.
code to test this below:
main.lua
io.output():setvbuf("no")
local cells = {}
local selectedCells = {}
local function unselectCells()
print "unselectCells()"
for i = 1, #selectedCells do
selectedCells[i].touched.isVisible = false
end
end
function handleEvent (event)
if event.phase == "began" then
print "touch began"
end
if event.phase == "moved" then
--print "touch moved"
end
if event.phase == "ended" then
print "touch ended"
timer.performWithDelay(500, unselectCells, 1)
end
tmpCell = event.target
tmpCell.touched.isVisible = true
if (tmpCell.spent == false) then
tmpCell.spent = true
table.insert(selectedCells, tmpCell)
end
end
function setupTable()
local startX = (display.contentWidth / 2) - 170
local startY = (display.contentHeight / 2) - 170
local tmpCell
for j=0,2 do
for i=0,2 do
cells[i] = display.newRect(0, 0, 160, 160)
tmpCell = cells[i]
tmpCell.spent = false
-- load buttons
tmpCell.touched = display.newRect(0, 0, 160, 160)
tmpCell.touched:setFillColor(140, 140, 140)
-- set button positions
tmpCell.x = startX + (i\*170)
tmpCell.y = startY + (j\*170)
tmpCell.touched.x = startX + (i\*170)
tmpCell.touched.y = startY + (j\*170)
tmpCell.touched.isVisible = false
-- add event listener to standard button
tmpCell:addEventListener("touch", handleEvent)
end
end
end
setupTable()
cofing.lua
application = {
content = {
width = 640,
height = 960,
scale = "letterBox",
fps = 30,
}
[import]uid: 13099 topic_id: 28413 reply_id: 328413[/import]