Problem with swiping in a native scroller

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
MrCrussell
Posts: 23
Joined: Wed Nov 05, 2014 11:30 am

Problem with swiping in a native scroller

Post by MrCrussell » Sun Nov 08, 2015 1:55 pm

Hi,

I have a scrolling 'table' which uses a group of rows to display a list of ingredients in a pantry. I'm using the native scroller (under IOS) to allow the user to scroll the list vertically, but I want to implement a horizontal swipe which will move the swiped row left to reveal a delete button where necessary (same behaviour as everyday IOS apps).

I used the code below within each row 'group' to detect mouseDown and mouseUp events, capturing the amount of horizontal movement in pixels so I can then decide if the user performed a swipe or a tap/click.

The problem is, as soon as I run the app in the sim or on device it doesn't seem to be firing the mouseUp event. A click/tap works fine, but if I click/tap. hold and drag then release, the release isn't being detected.

Any ideas where I might be going wrong? The native scroller uses the onScrollerDidScroll event - is that blocking something in some way?

Regards
Chris

Code in each 'row' group

Code: Select all

local sStartH

on mouseDown
    put the mouseH into sStartH
end mouseDown

on mouseUp
    put the mouseH into tMousePosn
    if abs( tMousePosn - sStartH ) > 50 then 
        put "Detected a swipe motion" 
        if ( tMousePosn > sStartH ) then 
            if (the left of me < -1 ) then 
                move me relative 120,0
            end if
        else
            if (the left of me = -1 ) then 
                if ( tMousePosn < sStartH) then
                    move me relative -120,0
                end if
            end if
        end if
    else
        put "Event is a CLICK - moving to EDIT card"
        set the cItemID of this stack to the short owner of the target
        visual effect push left fast
        go to card "editPantry"
    end if
end mouseUp

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Problem with swiping in a native scroller

Post by jacque » Sun Nov 08, 2015 4:59 pm

I've seen the same problem, it's a bug in LiveCode but I haven't had time to enter a report yet. If you do it, let us know and I'll add my comments. Otherwise I'll try to get to it myself pretty soon. I've been too busy to set up an example stack but since you already have one made it would be convenient if you could submit it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Problem with swiping in a native scroller

Post by quailcreek » Sun Nov 08, 2015 10:32 pm

Chris,
I see you have - put "Detected a swipe motion" in your code. There is no message box in iOS. I'm sure this isn't causing your problem but if you're trying to provide feedback you should use - answer "Detected a swipe motion". The same goes for - put "Event is a CLICK - moving to EDIT card"

Correct me if I'm wrong, Jacqueline.
Tom
MacBook Pro OS Mojave 10.14

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Problem with swiping in a native scroller

Post by quailcreek » Sun Nov 08, 2015 11:22 pm

I just happen to think. This could be related to a problem I reported with dataGrid scroller. It has to do with setting the scroller visible to true or false. Set to true the mouseUp doesn't fire, set to false it does. Might be worth looking into.

Code: Select all

mobileControlSet tCurrentScrollerID, "visible", true
http://quality.livecode.com/show_bug.cgi?id=15828
Tom
MacBook Pro OS Mojave 10.14

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Problem with swiping in a native scroller

Post by jacque » Mon Nov 09, 2015 2:56 am

quailcreek wrote:I just happen to think. This could be related to a problem I reported with dataGrid scroller. It has to do with setting the scroller visible to true or false. Set to true the mouseUp doesn't fire, set to false it does. Might be worth looking into.

Code: Select all

mobileControlSet tCurrentScrollerID, "visible", true
http://quality.livecode.com/show_bug.cgi?id=15828
Aha. I think that's it, the stack I was working with also needed to respond to both scrolling and taps. The lack of a mouseUp message forced us to change the user interface.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Problem with swiping in a native scroller

Post by quailcreek » Mon Nov 09, 2015 6:06 am

Great, glad we found the culprit. Thanks for adding to my bug report, Jacqueline. Maybe we'll get some traction. This actually work normally with LC 6
Tom
MacBook Pro OS Mojave 10.14

MrCrussell
Posts: 23
Joined: Wed Nov 05, 2014 11:30 am

Re: Problem with swiping in a native scroller

Post by MrCrussell » Mon Nov 09, 2015 8:12 am

quailcreek - nailed it :) As soon as I removed the statement mobileControlSet "arrowScroll", "visible", true normal behaviour returned.

I've been banging my head against the keyboard for two days over this - massive thanks for the tip!

Chris

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Problem with swiping in a native scroller

Post by jacque » Mon Nov 09, 2015 8:18 pm

quailcreek wrote:Chris,
I see you have - put "Detected a swipe motion" in your code. There is no message box in iOS. I'm sure this isn't causing your problem but if you're trying to provide feedback you should use - answer "Detected a swipe motion". The same goes for - put "Event is a CLICK - moving to EDIT card"

Correct me if I'm wrong, Jacqueline.
Responding to this a little late, but...you're correct. The "put" won't show up in the app itself. But I often use "put" without a destination for debugging because that will send it to stdout, and you can capture that output in Console (iOS) or Terminal (Android.) For Console, just choose "Open system log" in the Debug menu in the simulator. All the "put" statements will show up there.

Android is harder to configure so I sometimes fall back on plain "answer" dialogs just to avoid the setup. But sometimes dialogs destroy the flow of the script and aren't practical (and they're annoying anyway.) Instructions for setting up debugging in a terminal program are here:

<http://www.hyperactivesw.com/resources_ ... gging.html>

The iOS info in that article is out of date, use the trick above. I need to edit that page when I get a minute.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Problem with swiping in a native scroller

Post by quailcreek » Mon Nov 09, 2015 8:47 pm

Thanks, Jacqueline. I stand educated. :)

Looks like this will be fixed in 7.1.2 RC1
Tom
MacBook Pro OS Mojave 10.14

Post Reply