Android native scroller woes

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Android native scroller woes

Post by Tukcedo » Sat Nov 15, 2014 8:54 pm

LiveCoders,

I'm trying to get an area of my screen on Android to scroll, preferably without a vertical scrolbar (which works, but it's not very pretty). I've tried to follow this lesson:
http://lessons.runrev.com/m/4069/l/9441 ... ll-a-field

In my case, I've got a few different types of fields, buttons, text fields and, most importantly, a native browser control. This browser is contained in a group by itself and the objects I want to scroll are also grouped. The encompassing group has been resized to be smaller thant the total contents, so that about half the browser shows up. The idea is that you can see all of the browser by scrolling. Strangely enough, I never get any scrollerDidScroll events, so nothing ever happens. When the browser is activated, the contents is sized to fit the VISIBLE part, rather than stretch below into the part that's hidden from view (and where you'd scroll to to see it).
I tried putting the code in openCard as well but that doesn't make any difference and the values displayed are the same.

What am I missing folks?

Here's the code:

Code: Select all

local sScrollerID

on preOpenCard
   .....
   put the rect of group "ScrollRescue" into tScrollerRect
   put 0,0,(the formattedWidth of group "ScrollRescue"),(the formattedHeight of group "ScrollRescue") into tContentRect
   
   mobileControlCreate "scroller", "ScrollerRescue"
   put the result into sScrollerID
   
   # This says: Scroller: 14,96,350,598 Content: 0,0,353,658 ID: 4
   answer "Scroller: " & tScrollerRect && "Content: " & tContentRect && "ID: " & sScrollerID

   mobileControlSet "ScrollerRescue", "rect", tScrollerRect
   mobileControlSet "ScrollerRescue", "contentRect", tContentRect
   mobileControlSet "ScrollerRescue", "visible", true
   mobileControlSet "ScrollerRescue", "scrollingEnabled", true
   mobileControlSet "ScrollerRescue", "vIndicator", true
   mobileControlSet "ScrollerRescue", "vscroll", 0
end preOpenCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content 
   answer "Scroller H: " & hOffset && "V " & vOffset # this dialogue never appears
   set the vScroll of group "ScrollRescue" to vOffset
end scrollerDidScroll

on closeCard
    .....
    mobileControlDelete sScrollerID
end closeCard
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Android native scroller woes

Post by newtronsols » Sun Nov 16, 2014 12:22 am

Do you have set the fullscreenmode to "ExactFit" in your stack script?

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Sun Nov 16, 2014 7:05 am

Yes, I do. But the sample stack that's given in the example works. I also locked the size/position of the group.
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

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

Re: Android native scroller woes

Post by Simon » Sun Nov 16, 2014 7:20 am

Hi Michel,
I cannot say for certain but I don't think you can have a native control inside a native control. (I think that is what you are describing?)
For testing just do a simple stack with just the native browser inside a normal scroller, then try inside a native scroller.

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

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Sun Nov 16, 2014 9:26 am

Interesting point Simon, yes indeed the browser is a group inside of the larger one. The rest of the objects also don't scroll though but good suggestion, I'll try that today!
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Android native scroller woes

Post by newtronsols » Sun Nov 16, 2014 12:46 pm

Tukcedo wrote:Yes, I do. But the sample stack that's given in the example works. I also locked the size/position of the group.
I have been unable to get a scroller to work on android with fullscreenmode set.

Dear Runrev,

I'd love to see an example that allows a native scroller and fullscreenmode exactfit or any mode working together on android.

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Sun Nov 16, 2014 1:01 pm

The sample stack that is included in this lesson works for me. Built with LCC 7.0.1rc1

http://lessons.runrev.com/m/4069/l/9441 ... ll-a-field
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Sun Nov 16, 2014 7:28 pm

Unfortunately, it doesn't seem to be a problem with nested groups. I did a test with just basic controls and no groups but it still fails. The sample code from the lesson works so it should be possible, but when I replace it with my own code (see the attachment) it fails. The problem could be that the control doesn't register properly because I never receive any events from it. The debugger (adb logcat) doesn't seem to say too much about it, no obvious errors that I can recognise.

The code also shows a little bit of what I'd like: a card with a menu bar across the top, a scrolling area with a bunch of buttons and stuff in them and another bar across the bottom.
Attachments
menutest.zip
Test with scrolling group
(15.61 KiB) Downloaded 57 times
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

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

Re: Android native scroller woes

Post by Simon » Sun Nov 16, 2014 10:52 pm

Hi Michel,
It is working here, even with the openCard error. liveCode 6.6.1
I think you should get rid of the "canBounce" as that is iOS only.

This code is not working for you?

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

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Mon Nov 17, 2014 7:02 am

Two good suggestions to try tonight Simon: the bouncy thing and another version of LCC, thx. This is indeed a version that's not doing anything on my Sony Z1 Compact. What are you using to test it Simon?
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

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

Re: Android native scroller woes

Post by Simon » Mon Nov 17, 2014 7:10 am

HTC Android 2.3.5
Kindle Fire 4 point something.

Haven't tried the sim yet.

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

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Android native scroller woes

Post by newtronsols » Mon Nov 17, 2014 5:17 pm

All the scrollers I have created have had larger contentrect than the scroller rect [length or width].

I've always thought the idea was the scroller rect is a smaller area of a larger contentrect area - like looking through a car window driving on a road. The contentrect of the road being much larger than my car window rect. So I see it as I need/want to see it.

If I'm wrong please correct me.. I'd love to find out I'm entirely wrong with my perception of scrollers.

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Android native scroller woes

Post by Tukcedo » Mon Nov 17, 2014 6:39 pm

I'm by no means an expert but that's also my understanding of the scroller: the content's rect is larger than the rect of the scrolled area (the group).

Anyway, tested the code again according to Simon's tips. The canBounce makes no difference in LCC 7.0.1rc1, but I ran it with LCC 6.2.2 and it works like a dream. Hmmm I think I'll report this as a bug, I'll refer to this post as additional information. Thx Simon!

EDIT: the code which includes a group with a browser inside still doesn't behave properly, so it does seem as if nested groups (at least if it contains a browser control, others seem OK) can't be scrolled. Can be circumvented in my case by rearranging the screen layout somewhat.
EDIT 2: enabling canBounce has no effect but it also doesn't invalidate the scroller
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”