Widget 2.0 - Tableview - Android Build - Release/press Event Issues

I see, then yes a “cancelled” or “moved” event would be perfect. Thanks Danny!

A “cancelled” event would be good to have.

However you can temporarily get around this problem by declaring a tableView listener, and then check for a “moved” phase.

That worked with the following code:

[lua]

local function tableViewListener(event)

    local row = event.target

    if event.phase == “began” then

        row.alpha = 0.5

    elseif event.phase == “ended” then

        row.alpha = 1

    end

end

[/lua]

Thanks a lot!

I arrived here because ‘event.row’ was returning ‘nil’ for the event ‘release’ for me, and I was also hoping to find some clarity on “press” vs “tap” vs “release”. From what I’ve read on this thread, “tap” looks like the most sensible event to listen for when all you’re interested in is what row the user wants to select.

So I’m guessing ‘press’ and ‘release’ are more raw events, with which one could do fancier tableview footwork? Anyone have a clearer explanation of ‘press’ vs ‘release’ vs ‘tap’? What are circumstances where one would want to listen to ‘press’ and ‘release’ but not ‘tap’?

@fernandomgf

I’ve fixed the “tap” while scrolling issue in my fork of the OpenSource Widget 2.0.

@bobbycircle

Well, off the top of my head, I’d say that “tap” would be used when normally selecting a row.

Let’s say you’d like functionality to move rows up/down in a list. You’d listen for “press” to select the row for moving and “release” when you’ve moved it to where you want it.

I found out that the “release” phase does not fire if you press a row, drag then release. A feature like custom row background change on press and back to the original on release is not possible, the background will remain in the pressed state if the row is dragged. It used to work in version 1.

The following code is supposed to change the alpha of the row to 0.5 on press and back to 1 on release which works fine if you press then release but not if you press then drag the row then release:

[lua]

local function onRowTouch(event)

    local row = event.target

    if event.phase == “press” then

        row.alpha = 0.5

    elseif event.phase == “release” then

        row.alpha = 1

    end

end

[/lua]

That is intentional. Look at how it works on iOS natively. If you press then drag a row, after focus is removed from it (ie it’s highlight), the release event shouldn’t fire because the row is no longer active.

As a compromise I guess a “cancelled” event could be fired for the row in question. 

I see, then yes a “cancelled” or “moved” event would be perfect. Thanks Danny!

A “cancelled” event would be good to have.

However you can temporarily get around this problem by declaring a tableView listener, and then check for a “moved” phase.

That worked with the following code:

[lua]

local function tableViewListener(event)

    local row = event.target

    if event.phase == “began” then

        row.alpha = 0.5

    elseif event.phase == “ended” then

        row.alpha = 1

    end

end

[/lua]

Thanks a lot!