tableView inside scrollView

I’m currently building an app that uses tableView widgets inside a single scrollView widget.

All my buttons work fine inside the scrollView, however the tableView objects get stuck in the “press” phase when clicking it. I had the same problem for my buttons, but a simple “return true” statement released the “press” phase.

This doesn’t work for the tableView though, and as soon as you click it, it gets ‘stuck’. I tried setting the focus on the tableView, but I’m getting the error that I have a bad #-2 argument (proxy expected, got nil)

Any suggestions? [import]uid: 86582 topic_id: 28299 reply_id: 328299[/import]

Does anyone have a suggestion?

To sum it up real quick:

  • I have a tableView inside a scrollView
  • Clicking the tableView results in the event.phase not returning to “release”
  • The tableView locks because it’s stuck in the “press” phase [import]uid: 86582 topic_id: 28299 reply_id: 114452[/import]

Hey ferdiwillemse,

So you’ve got some kind of scrollable area that in a corner has a tableview list, right? Something like that?

The core problem is that widget.newScrollView() swallows the touch “ended” phase in order to operate. So you have to use “return true” on the table to keep that working. (newScrollView() has its own phases, by the way, which is helpful for general development but not helpful for the other widgets that expect to see “ended”)

…Or at least, that’s how I would have solved it before. I just tried making a sample project now and it seems that widget.newScrollView() swallows focus even if you tell the tableView to return true. If a dev doesn’t chime in you should file a bug.

Two things left to explore, though:
a. Are you using a mask?
(EDIT 1: By setting width/height, you need to use a mask. Try that and see what happens)

b. How are you setting focus (ie: sample code?) I had no errors attempting to set focus…but no luck actually setting focus either.
(EDIT 2: I don’t believe you can use “self” in the for loop since it’s not within a function or object. You would need to set focus to the variable name of the tableView instead)
[import]uid: 41884 topic_id: 28299 reply_id: 114461[/import]

Hi Richard,

Thanks for you response!

I edited the code for this example and accidentally gave it a “self” instead of the object name. I’ll edit it. In my original file I did use a mask, but left it out for this example as I noticed it resulted in the same behavior.

Normally putting a button inside a tableView would result in the same behavior of firing a “pressed” phase, after which the tableView steals the focus. Return true fixes this. However, like you said, this doesn’t work for the tableView inside a scrollView.

I’ll wait to see if anyone comes up with a solution, otherwise I’ll file a bug report.

Thanks again, Richard! [import]uid: 86582 topic_id: 28299 reply_id: 114466[/import]

Sorry for spamming, but here is a little piece of code, a stripped down version of my code.
Please test this and you’ll see what happens.

[code]local widget = require “widget”

local scrollView = widget.newScrollView( { width = 1024, height = 600, maskFile = “scroll_mask.png” } )

local tableView = widget.newTableView( { top=50, width=100, height=100, maskFile = “table_mask.png” } )
for i=1,20 do – loop to create 20 rows

local onRowTouch = function( e )

if e.phase == “press” then

– this event is fired
display.getCurrentStage():setFocus( tableView ) – doesn’t seem to do much
print( “pressed” )
return true

elseif e.phase == “release” then

– this event is never fired
print( “released” )

end

end

local onRowRender = function( e ) – render the row

local row = e.target
local rowGroup = e.view

local text = display.newRetinaText( “bla”, 12, 0, native.systemFont, 14 )
text:setReferencePoint( display.CenterLeftReferencePoint )
text.y = row.height * 0.5

rowGroup:insert( text )

end

tableView:insertRow { – create a row
onEvent=onRowTouch,
onRender=onRowRender,
height=30,
isCategory=false
}
end

scrollView:insert( tableView )[/code] [import]uid: 86582 topic_id: 28299 reply_id: 114460[/import]