scrollbars and vertical swipes

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

scrollbars and vertical swipes

Post by cusingerBUSCw5N » Sat Nov 03, 2012 7:14 am

I am testing my app and finding that the scrollbars are difficult to operate. I would like to set up a vertical swipe, but have no idea how to convert a swipe into moving a scrollbar down (or up).

Are there any examples of doing this successfully....or are there any better options than the standard scrollbars for datagrids on LiveCode? I tried making the scrollbars wider, and it helped a bit, but they are still awkward and don't move nicely.

Thanks.

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: scrollbars and vertical swipes

Post by gpb01 » Sat Nov 03, 2012 8:49 am

Sorry ... on which platform ?

If iOS ... he's already talked about here: http://forums.runrev.com/viewtopic.php?f=49&t=13141

Guglielmo

P.S. : Please, for these questions, use the correct section of the forum ... "iOS Deployment" for iOS and "Android Deployment" for Android ... :)

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Sun Nov 04, 2012 12:36 am

cool.... but what about Android???

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: scrollbars and vertical swipes

Post by gpb01 » Sun Nov 04, 2012 9:31 am

cusingerBUSCw5N wrote:cool.... but what about Android???
My sample here : http://forums.runrev.com/viewtopic.php? ... 141#p62803 use the "mobileControl........." functions which are mobile platform indipendent so, although I have not tried, should be work on both platforms (iOS and Android) :)

Guglielmo

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Tue Nov 13, 2012 5:53 am

I am still trying to find a good solution for vertical swipes with datagrids.

I am using datagrid forms because they can present information and images with a flexible layout.

I have two examples of vertical swipes (including the suggestion above - thank you) - but they do not use datagrids. I tried modifying the code using "dg" but it failed.

I tried looking at the mobgui, but it seems to not be supported - so I'm thinking that's a dead end.

I tried looking at TouchGrid, but that doesn't seem to allow loading information into the grid as a "form" - so I don't think that's a good option because I am trying to display text and pictures and the datagrid form is perfect.

The vertical scroll on the Android is awful - so some type of vertical swipe is necessary. So....here is my code based on the example given above

On the object script:

Code: Select all

global gIsScrolling

on mouseUp pBtnNum
     if gIsScrolling then 
         exit mouseUp
   end if
On the card script:

Code: Select all

global gIsScrolling
on opencard
   local tRect, tRealRect
   --
   if the environment is "mobile" then
      put the rect of group "datagrid help activity" into tRect
      answer trect
      put "0,0,0,0" into tRealRect
      put the width of group "datagrid help activity" into third item of tRealRect
      put the formattedheight of group "datagrid help activity" into twhat
      answer twhat
      put the formattedHeight of group "datagrid help activity" into fourth item of tRealRect
      --
      mobileControlCreate "scroller", "listScroller"
      --
      mobileControlSet "listScroller", "rect", tRect
      mobileControlSet "listScroller", "contentRect", tRealRect
      mobileControlSet "listScroller", "canBounce", "false"
      mobileControlSet "listScroller", "hIndicator", "true"
      mobileControlSet "listScroller", "vIndicator", "true"
      mobileControlSet "listScroller", "visible", "true"
      mobileControlSet "listScroller", "delayTouches", "true"
   end if
end opencard

on closeCard
   if the environment is "mobile" 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 pOffsetX, pOffsetY
   lock screen
  ## the original was:
##set the hscroll of field "mylist" to pOffsetX
  ## set the vScroll of field "mylist" to pOffsetY
## I changed it to:
set the hscroll of scrollbar "dgScrollbar" of group "dataGrid help activity"  to pOffsetX
set the vScroll of scrollbar "dgScrollbar" of group "dataGrid help activity"  to pOffsetY
   unlock screen
end scrollerDidScroll
and it failed.

I also tried it with
set the hscroll of group "dataGrid help activity" to pOffsetX
set the vScroll of group "dataGrid help activity" to pOffsetY

...it failed as well.

Sooo.....can anyone help me? :?

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Tue Nov 13, 2012 6:06 am

So I found a reference to horizontal scrolling and datagrids, saying that this code should be added in the script of the datagrid. I'm not sure where/how to use this. One of my datagrids is just a table format, so it doesn't have a row behavior....the others do....


on dgScrollbarDragH pScrollValue
set the hScroll of group "grpFilter" to pScrollValue
pass dgScrollBarDragH
end dgScrollBarDragH

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Tue Nov 13, 2012 6:17 am

OK...another piece of the puzzle. For datagrids, the parameter is dgHScroll and dgVScroll. Unfortunately, it still doesn't work. If this is put on the card stack, it never gets to this part of the code.

lock screen
set the dgHscroll of group "datagrid help activity" to pOffsetX
set the dgVScroll of group "datagrid help activity" to pOffsetY
unlock screen

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Tue Nov 13, 2012 6:46 am

so...still trying, I found this, which seems like it should work - but doesn't
(source http://lists.runrev.com/pipermail/use-l ... 73736.html)

on scrollerDidScroll OffsetX, OffsetY
send "dgScrollbarDragV "&OffsetY to group "datagrid help activities"
send "dgScrollbarDragH "&OffsetX to group "datagrid help activities"
end scrollerDidScroll

There are a couple of things not happening. If I put an answer "hi" on my datagrid's script, you get "hi" when you click on it - but not when you scroll. However, when you scroll, it does register on the card level that a scroll has begun and ended (in on scrollerEndDrag). But either way, it never hits the scrollerDidScroll - which is what tell it to actually do something. Something needs to happen for it to get to scrollerDidScroll...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: scrollbars and vertical swipes

Post by bn » Tue Nov 13, 2012 9:57 am

try to use dgformattedWidth and dgformattedHeight instead of formattedWidth and formattedHeight when using a datagrid.

So when you set the

Code: Select all

...
      put the dgformattedHeight of group "datagrid help activity" into twhat
      answer twhat
      put the dgformattedHeight of group "datagrid help activity" into fourth item of tRealRect
...
for a datagrid the normal formattedWidth/formattedHeight returns the width and tha height of the group. So there is nothing to scroll for the scroller since the contentRect is has the same dimension as the rect

Kind regards
Bernd

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Tue Nov 13, 2012 3:30 pm

Yes!!! Thank you!

it worked with this in scrollerDidScroll OffsetX, OffsetY

lock screen
set the dgHscroll of group "datagrid help activity" to OffsetX
set the dgVScroll of group "datagrid help activity" to OffsetY
unlock screen


and this in opencard

if the environment is "mobile" then
put the rect of group "datagrid help activity" into tRect

put "0,0,0,0" into tRealRect
put the width of group "datagrid help activity" into third item of tRealRect
put the dgformattedHeight of group "datagrid help activity" into fourth item of tRealRect
--
mobileControlCreate "scroller", "listScroller"
--
mobileControlSet "listScroller", "rect", tRect
mobileControlSet "listScroller", "contentRect", tRealRect
mobileControlSet "listScroller", "canBounce", "false"
mobileControlSet "listScroller", "hIndicator", "true"
mobileControlSet "listScroller", "vIndicator", "true"
mobileControlSet "listScroller", "visible", "true"
mobileControlSet "listScroller", "delayTouches", "true"
end if

along with scrollerbegindrag, scrollerenddrag, and the global variable (in code above)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: scrollbars and vertical swipes

Post by bn » Tue Nov 13, 2012 4:06 pm

Glad it worked.

Actually you don't have to set the dgHscroll since you only want to scroll vertically. It saves a tiny bit of processing time. The dgHscroll of the dataGrid never changes in your example.

Kind regards
Bernd

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Wed Nov 14, 2012 9:57 pm

Oh dear. 4 steps forward, 3 3/4 steps back.

From what I can tell, the verticalswipe capability is interfering with my mobilecontrol input fields.

I have laid out my card with different layers. The main layer has a datagrid where I just installed a vertical swipe scroll (works nicely, by the way...).... but when you click on a button, there is an overlay with a mobilecontrol input field (since livecode fields don't work on androids...which does NOT make me happy)...
The input field won't accept text. If I move it to an area without the scrollbar underneath - it works. Just setting the datagrid's vis to false doesn't do any good.

Before I redo my ap to have more cards instead of overlays - is there a workaround for this?...or does anyone know when Livecode will fix the problem with their input fields on androids?... it has caused me nightmare after nightmare.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: scrollbars and vertical swipes

Post by bn » Wed Nov 14, 2012 10:49 pm

just guessing, not tested:

in the script of group "myDataGrid" put a mouseDown and a mouseUp & mouseRelease

on mouseDown you set the contentRect to the dgFormattedHeight etc. (expand the scrolling area to the necessary height)
on mouseUp you set the contentRect to the height of group "myDataGrid" (just the area of the dataGrid group, basically a non functioning scroller)
on mouseRelease same as mouseUp

Kind regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: scrollbars and vertical swipes

Post by bn » Wed Nov 14, 2012 10:54 pm

You could also try to set the visible of the scroller to true on mouseDown and to false on mouseUp/mouseRelease.
Same logic as above

Kind regards
Bernd

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: scrollbars and vertical swipes

Post by cusingerBUSCw5N » Wed Nov 14, 2012 11:58 pm

Oh YES!!!! Thank you!!!

put this in the mouseup

if the environment is "mobile" then
mobileControlSet "listScroller", "visible", false
end if

opposite in mousedown and mouserelease.

I can enter data in the mobile control fields again!

Thank you

Post Reply