I’ve been working hard on a dynamic menu using a tableview widget as the base, however I ran into some trouble with it, and I *think* I have a solution, but I don’t like it right now.
I have not seen a tableview example that doesn’t take up 100% of the width of the screen, but that’s what I’m doing. (Because it’s just a simple “drop down” menu like the one shown here: https://www.google.com/design/spec/components/menus.html )
I’m highlighting a row onRowTouch using a transition so the background of the selected row quickly fades in. So imagine now that you’ve pressed on the row, the row lights up, then you move off it, just like with a button.
It seems like it should be easy to make it *cancel* the row selection, but I’ve had a heckuva time doing that. I wanted it to do whatever happens when you move the list up and down. I ended up getting the tableview widget code from github and adding the following, and I can’t decide if it’s something that ought to be there for everyone, or if there’s a much better way to do it, or what. I’m also pretty sure I’ve explained it all poorly, but any rate, here is the code I had to add to the tableview widget to make it work.
function view:touch( event ) ... if "moved" == phase and not self.\_isUsedInPickerWheel then -- Determine if the touch is still on the row or not local touchingRow = true local tx, ty = self:localToContent( 0, 0 ) if event.x \< tx or event.x \> tx + self.width then touchingRow = false end if (dy \< moveThresh and touchingRow) and self.\_initialTouch then
if event.phase ~= “ended” and event.phase ~= “cancelled” then
event.phase = “began”
end
else – it was moved or the user is not touching the row anymore
…
I really don’t want to have my own custom tableview widget because I want to get the updates and bug fixes and whatnot…
Thanks,
Dave