Page 1 of 1

How to combine native scrolling and tap in data grid

Posted: Tue Apr 15, 2014 3:49 am
by keram
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

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

Posted: Tue Apr 15, 2014 4:57 am
by Simon
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

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

Posted: Wed Apr 16, 2014 3:14 am
by keram
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

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

Posted: Wed Apr 16, 2014 3:22 am
by Simon
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