How to combine native scrolling and tap in data grid

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

How to combine native scrolling and tap in data grid

Post by keram » Tue Apr 15, 2014 3:49 am

Hello,

I'd like to somehow combine or rather use two handlers in data grid without interfering with each other.
One is in the Label in the Row Template and allows the user to tap on the particular record (text line) in the data grid and view that line in a separate card.
The code is:
on mouseUp
go cd "onelineview"
end mouseUp

The second is in for native scrolling and is in the card with data grid:

Code: Select all

on openCard
  
   ## native android scroller
   local tScrollerRect, tContentRect
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit openCard
   
   // Set the area of the scroller
   put the rect grp "DataGrid 1" into tScrollerRect
   
   // Set the area of the content to be scrolled
   put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") into tContentRect
   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0
   
end openCard

on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete sScrollerID
end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the DGvScroll of group "DataGrid 1" to vOffset
end scrollerDidScroll
How to make it possible so that when touching the screen to scroll will not trigger the first, "go to card" handler and yet use that first handler when necessary to go to another card?
Or are there another handlers that would make this combination work properly?

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to combine native scrolling and tap in data grid

Post by Simon » Tue Apr 15, 2014 4:57 am

Hi keram,
This may work for you;

Code: Select all

local isScrolling
on mouseUp
if not isScrolling then
--do your thing... go cd
end if
end mouseUp

on mouseDown
put false into isScrolling
end mouseDown

on scrollerDidScroll hOffset, vOffset
put true into isScrolling
set the vScroll of group "scrollArea" to vOffset
end scrollerDidScroll
You might have to pad scrollerDidScroll I'm not sure how sensitive it is.
Check out the padding in this lesson under Using swipe gestures.
http://lessons.runrev.com/s/lessons/m/4 ... r-the-ipad

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: How to combine native scrolling and tap in data grid

Post by keram » Wed Apr 16, 2014 3:14 am

Hi Simon,

Thanks for your code - it works very well :)

I checked that section on swipe gestures. By padding, do you mean to define the range of the swipe (start and end points of the touch and calculating how far the user has swiped)?

Is the sensitivity (the range of the swipe?) controlled only by the code or it depends on the OS of the mobile as well? Or maybe by the hardware as well?

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to combine native scrolling and tap in data grid

Post by Simon » Wed Apr 16, 2014 3:22 am

By padding, do you mean to define the range of the swipe (start and end points of the touch and calculating how far the user has swiped)?
Yes, make sure it's not just a mistake.
The range (distance) of swipe is indicates if there actually been one worth acting on.

But I didn't test my code so you might not need it.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply