DelayTouches for Android?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

DelayTouches for Android?

Post by sincipient820 » Tue Apr 30, 2013 1:44 am

I have a scrolling list field and added a native iOS type scroller to the field... It scrolls great, however, the list selection behavior is not ideal... when the user initiates scrolling it selects lines in the field... for multi select fields this is especially problematic because it highlights a whole string of lines... I am aware of the following iOS code to prevent such behavior...
mobileControlSet pName, "delayTouches", true
is there a similar delayTouches code for Android?... or do I have to get innovative?... thanks

nuis
Posts: 3
Joined: Mon May 06, 2013 5:11 pm

Re: DelayTouches for Android?

Post by nuis » Mon May 06, 2013 5:21 pm

Hello,
I am facing the exact same issue. How can I prevent a selection when i just want to scroll.
I am using the mobileControlSet scroller. I see, at least in the iOS simulator, that this is handled niceley there,
even without setting that property. On an android device the scrolling is interrupted by the touches that select and hilite lines in the list i am scrolling.

Is there any walkaround maybe by some extra code for that?

Thanks

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

Re: DelayTouches for Android?

Post by jacque » Mon May 06, 2013 5:49 pm

All Android scrolling fields will always briefly hilite the touched line before responding, so that part is normal. What I do is check in a scrollerDidScroll handler to see if the scroll has changed more than a few pixels (I usually use about one line height, but experiment.) If there's been enough movement, it's a scroll. If not, then it's a tap and I respond by calling the appropriate handler. I don't use mouseUp to determine taps in Android.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nuis
Posts: 3
Joined: Mon May 06, 2013 5:11 pm

Re: DelayTouches for Android?

Post by nuis » Mon May 06, 2013 8:07 pm

Thank you for the hints. I am having a try on your suggestions but
also having a hard time to find out how far the scroll did change.

Just ended up with the following lines:

Code: Select all

on scrollerDidScroll hOffset, vOffset
   
     if vOffset > the vScroll of group "MyScrollGroup" then
      put vOffset - the vScroll of group "MyScrollGroup" into tDiff
    else
      put the vScroll of group "MyScrollGroup" - vOffset into tDiff
    end if
  
    if tDiff > 20 then
      set the vScroll of group "MyScrollGroup" to vOffset
    else
      put the selectedtext of fld MyList into fld SelectedLine
    end if
   
end scrollerDidScroll
But that does not work because the tDiff variable always ends up under the threshold.
I am not sure how to get that comparison of the change to work.How are you making that check ? :)

If I understand you right, a touch on the group and the inside List will always select and hilite the touched line. I really want to avoid that too.
I thought about disabling the autohilite property of the List at all and make the selection manually (when a tap is detected) depending on the actual mouse position. Is that somehow doable? Could i activate the autohilite for that moment and maybe send a fake touch start at that mouse position? maybe i am thinking too complicated?
I am quite new to LC and just starting to grasp the concepts, so sorry if that is a little stupid question :)

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

Re: DelayTouches for Android?

Post by jacque » Mon May 06, 2013 8:56 pm

Actually, here's an easier way:

Code: Select all

local sStartPx

on mousedown
  put the mouseV into sStartPx
end mousedown

on mouseUp
  if abs(the mouseV - sStartPx) > 10 then pass mouseUp -- scrolling/dragging; adjust distance here
  -- tap code here
end mouseUp
What I meant when I said that hiliting was normal behavior is that the Android OS does that. If you run almost any Android app that allows a scrolling field to also accept taps, you'll see the line hilite briefly before it starts moving. The above code will do the same thing. However, I'd assumed you are using a native Android input field. The underlying LiveCode field should not have autohilite set at all, the input field handles that.

If you are using only a LiveCode field, things get trickier and scrolling won't be as smooth. You could toggle the autohilite property off on mouseDown but you'd still see a brief flash before it shuts off.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

PaulMaguire
Posts: 44
Joined: Wed Feb 13, 2013 3:38 pm
Contact:

Re: DelayTouches for Android?

Post by PaulMaguire » Tue May 07, 2013 10:42 am

Just a thought - does setting the lockText property of the field to TRUE avoid the selection issue?

I'm just about to embark on making my iOS LC project Android-friendly - keen to know any such gotchas...

Kind regards, Paul.

nuis
Posts: 3
Joined: Mon May 06, 2013 5:11 pm

Re: DelayTouches for Android?

Post by nuis » Tue May 07, 2013 12:31 pm

Thank you for the explanation and the snippet, that handling is very charming.
Have still much to learn. :)
It works very nice for my scrollers.
I will give the native android field a try also.
Have a nice day jacque

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

Re: DelayTouches for Android?

Post by jacque » Tue May 07, 2013 6:53 pm

PaulMaguire wrote:Just a thought - does setting the lockText property of the field to TRUE avoid the selection issue?

I'm just about to embark on making my iOS LC project Android-friendly - keen to know any such gotchas...

Kind regards, Paul.
Actually I think the locktext has to be true regardless. If it isn't locked you can't scroll at all, you'll get the insertion point when you tap.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

Re: DelayTouches for Android?

Post by sincipient820 » Wed May 08, 2013 7:00 pm

Thanks Jacque,

I actually had already applied a similar code to identify whether it was scrolling, tapping or nothing... on tap it saves the selections to a cProperty and then on ScrollerEndDrag (after scrolling stops and there is no action) it displays them.... this is in part where the problem lies.... for example, if i select the line 1 then scroll down 20 lines on ScrollerEndDrag it will re-highlight line 1 as desired.... in doing so it resets to the position where line 1 is visible in order to highlight it .... so if the user wanted highlight line 1 AND line 20 they would not be able to do it because on ScrollerEndDrag it would reset to make line 1 visible before the user would get to tap line 20....So, I'm assuming I can now hammer in some code that identifies the position of ScrollerEndDrag and then re-highlight line 1 and then reset the position to the position of ScrollerEndDrag .... however, I would assume that would look kinda glitchy as it jumps between orders very quickly.... hence the reason Im inquiring whether there is a DelayTouches equivalent for Android... but looks like this has to get coded in... any ideas to make this smooth?

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

Re: DelayTouches for Android?

Post by jacque » Wed May 08, 2013 7:37 pm

I think I see now. The problem is that selecting more than one line, on the desktop at least, requires that a control key of some type be depressed -- shift, command, control, etc. And of course on mobile you can't do that and Android doesn't have the equivalent of delaytouches.

I haven't needed to use a multi-select field yet, but the first thing I'd try would be to just lock the screen, set the (new) hilitedlines, reset the field scroll, and then unlock the screen. Visually nothing should move. If that's too tricky, you could try turning off autohilite on mousedown and then turning it back on in mouseup.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

Re: DelayTouches for Android?

Post by sincipient820 » Fri May 10, 2013 8:54 pm

Your suggestions seem to work great... thanks

Post Reply