Hello,
Is there a way to achieve the same effect scrollView:takeFocus has but with a tableView? I currently have a rect placed on top of my tableView and I’m trying to pass the touchFocus on to the tableView if the event.phase of the rect is ‘moved’. My current code is like so but it’s not working:
-- Touch listener
local function touchListener(event)
local phase = event.phase
local x = event.x - event.xStart
local y = event.y - event.yStart
if(phase == 'began') then
--[[
if(y \> 5) then
return false
end
--]]
elseif(phase == 'moved') then
if(y \> 5) then
--display.getCurrentStage():setFocus(tableView)
--display.getCurrentStage():setFocus(tableView.content)
--event.target:dispatchEvent({name='touch', phase='began', y=12, yStart=6, x=0, xStart=0})
return false
end
end
if(y \<= 5 and phase == 'moved' or phase ~= 'moved') then
return true
end
end
-- Touch rect
local touchRect = display.newRect(0, 0, 60, 480)
touchRect:setFillColor(255, 0, 0)
touchRect:addEventListener('touch', touchListener)
group:insert(touchRect)
I’ve tried dispatching events manually & setting the stage focus on the tableView and tried returning false but neither solution seems to be working… Does anyone know if this is possible to achieve?
Thanks! [import]uid: 14018 topic_id: 34203 reply_id: 334203[/import]
Seems like I was trying tableView.content:takeFocus() for some reason. Did the normal way and it’s working beautifully now. Thanks a lot! [import]uid: 14018 topic_id: 34203 reply_id: 136081[/import]