Hi,
I have two scenes. I move from one another by swiping the screen. There is an overlaying invisible rectangle in each screen designated to swipe gesture detection
In a scene I added a tableview covering the entire screen and now conflict over focus between tableview and rectangle arises.
Basically if I put a return true in the function that handle the swipe detection for the rectangle I can’t scroll the tableview and viceversa.
I was thinking about discerning between horizontal and vertical swipes (the tableview doens’t have swipeable rows so I don’t need it to handle horizontal swipes) as a method to pass focus to the interested object, but this is advanced stuff for my level of programming skill.
So if anyone could point me at the right direction to start with this it would be greatly appreciated.
Here’s the code I am using so far:
---------- this below is just to set the tableview and 4 rows --------------------- tableView = widget.newTableView { left = 0, top = 28, height = display.contentHeight - 100, width = display.contentWidth, hideBackground = true, onRowRender = onRowRender, onRowTouch = onRowTouch, listener = scrollListener } sceneGroup:insert(tableView) local isCategory = false local rowHeight = 75 local rowColor = {default = { 1, 1, 1, 0 } } local lineColor = {1, 1, 1, 0} for i = 1, 4 do numContainer[i] = 0 namesContainer[i] = i tableView:insertRow({ isCategory = isCategory, rowHeight = rowHeight, rowColor = rowColor, lineColor = lineColor, onEvent = onRowTouch, onRender = onRowRender, }) end ------------ here I create the rectangle --------------------- local swipeLayer = display.newRect( centerX, centerY, display.contentWidth, display.contentHeight ) swipeLayer.alpha=0 --make it transparent swipeLayer.isHitTestable = true sceneGroup:insert( swipeLayer ) swipeLayer:toFront( ) -------------- and this below is the function to detect the swipes and change scene accordingly --------- local function startDrag(event) local swipeLength = math.abs(event.x - event.xStart) print(event.phase, swipeLength) local t = event.target local phase = event.phase if "began" == phase then return true elseif "moved" == phase then elseif "ended" == phase or "cancelled" == phase then if event.xStart \> event.x and swipeLength \> 50 then print("Swiped Left") elseif event.xStart \< event.x and swipeLength \> 50 then print( "Swiped Right" ) composer.gotoScene("counter", {effect="iosSlideRight01", time= 400}) end end end
I’ll keep on trying figure out a solution but in the meanwhile any suggestion will be helpful…
Thanks a lot!!!