Saving the scroll position in a scrolling list field

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

Post Reply
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Saving the scroll position in a scrolling list field

Post by glenn9 » Fri Feb 12, 2021 1:40 pm

Hi,

I've got a scrollling list field of items on Card A which when an item is tapped, navigates to a linked different card, ie a simple notes app.

As the scrolling list field now contains over a 100 items I was wanting to see if I could code returning to the same item, ie the same position in the scrolling list field, that was tapped when navigating back to card A from another card.

I was hoping the 'thumbposition' command might help but on checking the dictionary and despite this with some trial error, I don't think this is the correct command as I can't seem to put the 'thumbposition' into a variable that I can then reference, to return to a particular position in card A.

It might not even be possible but I just wanted to check!

Many thanks,

Glenn

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: Saving the scroll position in a scrolling list field

Post by elanorb » Fri Feb 12, 2021 1:48 pm

Hi Glenn

I think you might be looking for the vScroll property, rather than the thumbposition.

I hope that helps.

Elanor
Elanor Buchanan
Software Developer
LiveCode

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Saving the scroll position in a scrolling list field

Post by richmond62 » Fri Feb 12, 2021 2:05 pm

I would have thought the best idea would be to SAVE the stack just before it navigates to the new card, thereby
preserving the scrollBar at the position it is before going to the new card.
-
Screenshot 2021-02-12 at 15.00.46.png
-
Here's the code in my scrolling list field:

Code: Select all

on mouseUp
   save stack "SHUFFLE"
   put the selectedLine of me into ZZZ
   set the itemDelimiter to " "
   put item 2 of ZZZ into XXX
   put line XXX of fld "scf" into KARD
   go to card KARD
end mouseUp
Attachments
SHUFFLE.livecode.zip
(1.17 KiB) Downloaded 190 times

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by glenn9 » Fri Feb 12, 2021 2:06 pm

Thanks Elanor, that works perfectly!

I've used on card A:

Code: Select all

put the vScroll of field 1 into gScrollPosition

and on card B:

Code: Select all

set the vScroll of field 1 of card A to gScrollPosition
I never ceased to be amazed at how straightforward LC can be, especially for me as a beginner!

Kind regards,

Glenn

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by glenn9 » Fri Feb 12, 2021 2:11 pm

Hi Richmond,

Thanks for the stack, I'll put your solution into my toolbox as well...

Regards,

Glenn

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving the scroll position in a scrolling list field

Post by Klaus » Fri Feb 12, 2021 2:30 pm

Saving the stack is of course no option in a runtime!

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by bogs » Fri Feb 12, 2021 2:35 pm

Klaus wrote:
Fri Feb 12, 2021 2:30 pm
Saving the stack is of course no option in a runtime!
Unless your using the standalone as a launcher for your program stacks... :D
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving the scroll position in a scrolling list field

Post by Klaus » Fri Feb 12, 2021 2:45 pm

Sheeeeeeeeesh... 8)

Noone likes wise guys, Sir!

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by bogs » Fri Feb 12, 2021 2:53 pm

Capone did :twisted:
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving the scroll position in a scrolling list field

Post by Klaus » Fri Feb 12, 2021 3:05 pm

Where do you live again? 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Saving the scroll position in a scrolling list field

Post by richmond62 » Fri Feb 12, 2021 3:12 pm

Probably somewhere near the bag end of Lake Michigan, I imagine. 8)

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by bogs » Fri Feb 12, 2021 3:13 pm

Endurance impact crater, Mars !

Image
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving the scroll position in a scrolling list field

Post by Klaus » Fri Feb 12, 2021 3:20 pm

Ah, good for you. :D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Saving the scroll position in a scrolling list field

Post by bogs » Fri Feb 12, 2021 3:45 pm

Hee hee :D
Image

Post Reply