CoronaSDK - clip the lisview using tableview library

I have a navbar at the top of a screen with a listview using tableview.lua. The problem is that, even in the sample code for the listview samples, you can click on the navbar, and the capture phase will not end at the navbar, but instead continues all the way to the listview. This makes it so that, as soon as you scroll the list underneath the navbar, any click on the navbar captures the click on the list item instead of on the navbar buttons. I’ve tried to add the navbar group back to the maingroup on the handler, but that doesn’t seem to work (visually, it’s still on top, anyway). I also tried returning true when the navbar button was clicked to end the capture phase, but that didn’t work, either.

I want to be able to go from one listview to another (drill-down type of application), but that’s a problem right now as you can’t scroll the list and then access the navbar. Any ideas?
[import]uid: 19999 topic_id: 18636 reply_id: 318636[/import]

Well, I think the problem is that while return true probably works fine for the buttons I don’t think it helps you with the bar itself. - I guess you would need to set another handler on that.

This is probably a dumb question, but have you tried setting focus? [import]uid: 41884 topic_id: 18636 reply_id: 71586[/import]

I’m having this same issue. Has anyone resolved this? @richard9 could you please explain what you mean by setting the focus, focus of which object? [import]uid: 59380 topic_id: 18636 reply_id: 72741[/import]

Focus is a method of restricting what is executed to a single object (usually the object on top). That’s the really vague explanation anyway, but basically, if you have something overtop of something else, and you only want the topmost piece to be clickable, you need to do something like this:

[code]
– Usually onTouch(event) but whatever
myFunctionwhateveritscalled = function(event)

if phase == “began” then
– Sets the focus to the object you just clicked on.
display.getCurrentStage():setFocus(whatevermyobjectnameis)
– other stuff

elseif phase == “end” then
– Drop focus
display.getCurrentStage():setFocus(nil)

– other stuff
end

– Also important to lock down the focus, I think…?
return true
end[/code]

(Obviously this is not a seperate function, but bits that should be integrated into your current touch function.)

Right now I use that exact code (along with whatever else I need) to make a draggable object inside of scrollview. When you touch the object, you can drag the object but not scroll the screen by using this code. [import]uid: 41884 topic_id: 18636 reply_id: 72745[/import]

@richard9,
Thanks for your quick reply, and suggestion to set the focus. Sorry about the slow reply (last week of classes–lot’s of projects to grade, etc.). I tried setting the focus and, although I was able to see through print statements to the terminal that I was getting the touch event of the thing being clicked, the click was still propagating to the layers below.

Ends up I was close to the solution, but was off just enough to cause frustration. The event (a scene change) occurred on an “ended” phase. I needed to put a “return true” statement in the “began” phase in order to stop the click from propagating. Hopefully, this helps others who might face the same thing. The code looks like this
[lua] function changeScene(e)
if (e.phase ==“began”) then
return true
end
if(e.phase == “ended”) then
audio.play(click_sound);
director:changeScene(“menu”, “moveFromLeft”);
end
end[/lua] [import]uid: 19999 topic_id: 18636 reply_id: 73236[/import]

Hey, don’t worry about reply times. It’s the same for all of us - I try to answer when I can but sometimes I’m just either too bogged down with work on my own project. :slight_smile: [import]uid: 41884 topic_id: 18636 reply_id: 73252[/import]