Slider Control with Native Scroller

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Slider Control with Native Scroller

Post by dcpbarrington » Tue Mar 03, 2015 8:32 pm

Forum,

I have a card that has multiple controls that is larger then the display view, so I have created a Native Android Scroller for the page.

The problem is that the Slider Control does not allow the user to slide the slider smoothly because of the Native Android Scroller. Don't know if anyone else has run into this.

So I added message handlers to the Livecode slider to disable the Native Android Scroller when the user touches in the slider and then enable it again when the user stops touching the slider. I've implemented the functionality with both the mouseDown/mouseUp and touchStart/touchEnd message in the attached stack.

The problem is that when the user touches the slider, the slider doesn't slide until you touch it a second time. I've put a Debug field on the card and the slider gets the mouseDown or touchStart message when the user touches the slider, but the slider will not move until you release the touch and touch it again. No Messages are received. You can then slide the slider and you get a mouseUp / touchEnd message when you release the touch of the slider.

Looks like you need to double tap the slider to get it to slide. Is this how it should work or is it a bug?
Not a very good user experience, but at least the slider move smoothly after you get it to slide.

Any recommendation?
Thanks
dan
Attachments
NativeScrollMultiSlider.zip
Card with scroller and multiple slider contorls
(8.09 KiB) Downloaded 283 times

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Slider Control with Native Scroller

Post by MaxV » Wed Mar 04, 2015 11:10 am

Since you use livecode scroller, you can add a simple vertical scroll to the group. Use the property inspector, in the basic properties page.
No code needed.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Slider Control with Native Scroller

Post by dcpbarrington » Wed Mar 04, 2015 5:54 pm

MaxV

Thanks for your reply. Using the Group scrolling option improves the Slider functionality, but eliminates the ability for the user to scroll the page content by touch. They need to use the scroll bar on the side to move the content up and down the page. It works, but is different from all the other parts of the app,

If there is no other way to do this, I will need to use this option, but it reduces the ease of use for the mobile app.

Any other idea on how to turn on and off vertical scrolling when you touch the slider?

Other Note:
I think the reason for the double touch requirement I think is due to the first touch disabling the Native Scrolling and the second touch activates the slider control.

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

Re: Slider Control with Native Scroller

Post by jacque » Wed Mar 04, 2015 6:12 pm

I've implemented the functionality with both the mouseDown/mouseUp and touchStart/touchEnd message in the attached stack.
Don't use both sets of handlers, remove the touch ones. MouseUp and mouseDown work fine in mobile and are all you need unless you are tracking multi-touch events.

The way it is now the engine is sending two sets of responses on every touch.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Slider Control with Native Scroller

Post by dcpbarrington » Wed Mar 04, 2015 6:45 pm

Found a solutions.

To get this to work smoothly do the following.

Define the following handlers in the slider control

Code: Select all

on touchStart
   put the uScrollID of this card into tScrollID
   if tScrollID > 0 AND tScrollID is not Empty then
      mobileControlSet tScrollID, "scrollingEnabled", false
   end if
end touchStart

on touchEnd
   pass touchEnd
end touchEnd

on touchRelease
   pass touchRelease
end touchRelease

on scrollbarDrag pValue
   
   put the uOutputLocation of me into tLocation
   put pValue into fld tLocation
   
end scrollbarDrag
Now this disables the native scroller when you touch a slider control. To re-enable the native scroller add the following handler to the card to re-enable the native scroller when the user touches outside of the slider.

Code: Select all

on touchStart pID
   put the uScrollID of this card into tScrollID
   if tScrollID > 0 AND tScrollID is not Empty then
      mobileControlSet tScrollID, "scrollingEnabled", true
   end if
   pass touchStart pID
end touchStart
Worked like a champ to still allow the touch scrolling, but with a slider that worked as expected.

Post Reply