Page 2 of 2
Re: scrollbars and vertical swipes
Posted: Thu Nov 15, 2012 12:24 am
by bn
Glad it worked.
if the environment is "mobile" then
mobileControlSet "listScroller", "visible", false
end if
opposite in mousedown and mouserelease.
If I am not mistaken you should put
mobileControlSet "listScroller", "visible", false
into mouseRelease.
MouseRelease is a message that is sent instead of mouseUp if the mouseUp occcurs outside of the control that got the mouseDown: then instead of a mouseUp a mouseRelease is sent to that control.
Suppose you swipe outside of the bounds of the datagrid and lift your finger: a mouseRelease is sent.
Kind regards
Bernd
Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 7:01 am
by cusingerBUSCw5N
Losing my mind with scrollbars and vertical swipes....on the Android. First - I removed the extra code discussed previously because it was interfering with clicking on the item. So I rewrote everything to move the input fields away from the datagrids with scrollbars. So now I'm just dealing with datagrids with vertical swipe scrollbars on an Android.
My vertical swipe scrollbar doesn't work...and it works...
In my test stack, it works. You can swipe down and you can choose a document. It's lovely.
When I put it in my main stack, it doesn't work (or it sometimes works a bit sporadically - not at all smoothly like the test stack). You can see part of the scrollbar moving, but the items don't move. I stripped all the other cards and all the other code, including the code at the stack level so it matches the test stack and it still doesn't work. I removed everything I could find to see where there might be a conflict - so I just have the datagrid, a button to load the datagrid and the card script to operate the scroll.
My test works on an Android, my other one doesn't.
I'm including the url for the one that works here:
http://www.toolsforbusiness.info/test_stack.livecode
and the url for the one that doesn't work here:
http://www.toolsforbusiness.info/disast ... 3.livecode
I have probably been staring at this for way too long and it's obvious to someone else, but I am losing my mind.

Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 4:22 pm
by cusingerBUSCw5N
Here is the code of the one that doesn't scroll with your finger:
Card script:
Code: Select all
global gIsScrolling
on opencard
local tRect, tRealRect
if the environment is "mobile" and the platform is "android" then
put the rect of group "datagrid 1" into tRect
put "0,0,0,0" into tRealRect
put the width of group "datagrid 1" into third item of tRealRect
put the dgformattedHeight of group "datagrid 1" into twhat
put the dgformattedHeight of group "datagrid 1" into fourth item of tRealRect
--
mobileControlCreate "scroller", "listScroller"
--
mobileControlSet "listScroller", "rect", tRect
mobileControlSet "listScroller", "contentRect", tRealRect
mobileControlSet "listScroller", "canBounce", "false"
mobileControlSet "listScroller", "hIndicator", "false"
mobileControlSet "listScroller", "vIndicator", "true"
mobileControlSet "listScroller", "visible", "true"
mobileControlSet "listScroller", "delayTouches", "true"
end if
end opencard
on closecard
if the environment is "mobile" and the platform is "android" then
mobileControlDelete "listScroller"
put false into gIsScrolling
end if
end closecard
on scrollerBeginDrag
put true into gIsScrolling
end scrollerBeginDrag
on scrollerEndDrag
put false into gIsScrolling
end scrollerEndDrag
on scrollerDidScroll OffsetX, OffsetY
lock screen
set the hscroll of field "datagrid 1" to pOffsetX
set the vScroll of field "datagrid 1" to pOffsetY
unlock screen
-- lock screen
-- set the hscroll of field "label_tasklist" to pOffsetX
-- set the vScroll of field "label_tasklist" to pOffsetY
-- unlock screen
end scrollerDidScroll
object script:
Code: Select all
on mouseup pBtnNum
###if the environment is "mobile" and the platform is "android" then
###mobileControlSet "listScroller", "visible", false
###end if
if gIsScrolling then
exit mouseUp
end if
if pBtnNum is 1 then
put the dgHilitedLines of group "Datagrid 1" into theLine
put the dgDataOfLine[theLine] of group "Datagrid 1" into theDataA
## theDataA is now an array variable.
## In the case of the Data Grid pictured above the keys of the array are Link Address and Topic
## This answer dialog will display: Link Address
if char 1 of theDataA["Link Address"] is " " then
delete char 1 in theDataA["Link Address"]
end if
replace " " with "%20" in theDataA["Link Address"]
if char -1 of theDataA["Link Address"] is "_" then
answer "There is no link information for this line."
else
if theDataA["Link Address"] is "" and word 1 of the target <> "Scrollbar" then
answer "There is no link information for this line."
else
put "http://www.toolsforbusiness.info/disaster/docs/" before theDataA["Link Address"]
if word 1 of the target <> "scrollbar" then
answer theDataA["Link Address"]
end if
end if
end if
end if
end mouseUp
--on mouserelease
-- if the environment is "mobile" and the platform is "android" then
-- mobileControlSet "listScroller", "visible", true
-- end if
--end mouserelease
--on mousedown
-- if the environment is "mobile" and the platform is "android" then
-- mobileControlSet "listScroller", "visible", true
-- end if
--end mousedown
Stack script is empty
Standalone settings - touchscreen is clicked as "used"
Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 4:24 pm
by cusingerBUSCw5N
oops...I forgot the button
Code: Select all
on mouseUp
put the width of this stack into tstackwidth
put "http://www.toolsforbusiness.info/disaster/disaster_getdocs.cfm?email=cusinger99@comcast.net&password=carolynkits" into turl
put url (turl) into theData
replace "xyz" with return in theData
replace "usetab" with tab in theData
--add data
put false into firstLineAreNames
set the dgText[firstLineAreNames] of group "DataGrid 1" to theData
answer theData
set the dgColumnWidth["topic"] of group "DataGrid 1" to (tStackWidth - 20)
set the dgColumnIsVisible["link address"] of grp "DataGrid 1" to false
put the dgNumberOfLines of group "DataGrid 1" into tlines
put the dgDataOfLine[1] of group "DataGrid 1" into theDataX
if theDataX["topic"] is empty or theDataX["topic"] is "" or theDataX["topic"] is "" then
put 1 into theLineX
send "DeleteLines theLineX" to grp "DataGrid 1"
end if
end mouseUp
Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 6:49 pm
by gpb01
Mmm ... to scroll a DataGrid you have to use the "
dgHScroll" and "
dgVScroll" DataGrid properties and NOT hscroll and vscroll !!!
See pag. 222 of LiveCode DataGrid pdf
Guglielmo
Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 10:00 pm
by cusingerBUSCw5N
Hi. Sorry about that - yes, you're right, but it didn't fix it
Code: Select all
global gIsScrolling
on opencard
local tRect, tRealRect
if the environment is "mobile" and the platform is "android" then
put the rect of group "datagrid 1" into tRect
put "0,0,0,0" into tRealRect
put the width of group "datagrid 1" into third item of tRealRect
put the dgformattedHeight of group "datagrid 1" into twhat
put the dgformattedHeight of group "datagrid 1" into fourth item of tRealRect
--
mobileControlCreate "scroller", "listScroller"
--
mobileControlSet "listScroller", "rect", tRect
mobileControlSet "listScroller", "contentRect", tRealRect
mobileControlSet "listScroller", "canBounce", "false"
mobileControlSet "listScroller", "hIndicator", "false"
mobileControlSet "listScroller", "vIndicator", "true"
mobileControlSet "listScroller", "visible", "true"
mobileControlSet "listScroller", "delayTouches", "true"
end if
end opencard
on closecard
if the environment is "mobile" and the platform is "android" then
mobileControlDelete "listScroller"
put false into gIsScrolling
end if
end closecard
on scrollerBeginDrag
put true into gIsScrolling
end scrollerBeginDrag
on scrollerEndDrag
put false into gIsScrolling
end scrollerEndDrag
on scrollerDidScroll OffsetX, OffsetY
lock screen
set the dgHScroll of field "datagrid 1" to pOffsetX
set the dgVScroll of field "datagrid 1" to pOffsetY
unlock screen
end scrollerDidScroll
same problem. It seems that something is scrolling in the back (I can see it go up and down), but there is part of the scroll that isn't moving. Am I supposed to be disabling the existing scroll in order to put a mobilecontrol over it???
Re: scrollbars and vertical swipes
Posted: Mon Nov 19, 2012 10:22 pm
by gpb01
First the DataGrid is not a
field but a
group so ...
Code: Select all
on scrollerDidScroll OffsetX, OffsetY
lock screen
set the dgHScroll of group "datagrid 1" to pOffsetX
set the dgVScroll of group "datagrid 1" to pOffsetY
unlock screen
end scrollerDidScroll
... next, yes, you have to disable the scrollbars of the DataGrid because you are using the scroller values to scroll.
Guglielmo
Re: scrollbars and vertical swipes
Posted: Tue Nov 20, 2012 2:50 am
by cusingerBUSCw5N
Problem SOLVED.
Yes, you were right about the field as well. I was copying code from a scrolling field and being stupid about it....but that wasn't my real problem.
On my actual app, I incorrectly put the scrolling script on opencard - BEFORE I set any height for the datagrid. I am loading the datagrid through a button - and when I moved the script to the button - and put it after I loaded the data to create the height - voila - is scrolls.
So...I have learned:
1) use "group" when referring to a datagrid
2) use dgVscroller when referring to a datagrid
3) Put the script after Livecode knows what's going in the datagrid so it has a height to work with in this line:
put the dgformattedHeight of group "datagrid 1" into fourth item of tRealRect
(mine was 0)
Thank you all.

Re: scrollbars and vertical swipes
Posted: Tue Jul 30, 2013 4:23 am
by blanco
please i need help on scrolling a datagrid on android.I followed the post on this page and have created a data grid with 20 elements out of which 7 of them are initially visible. from the code snippests from this page , i am eable to get the scroller on the datagrid but when i scroll i can not get past the first 7 visible entries in my datagrid.thanks for your help in advance