ScrollLineIntoView not working on iOS Simulator

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
Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

ScrollLineIntoView not working on iOS Simulator

Post by Bellballer1 » Mon Sep 20, 2021 4:01 pm

Hello,

My app has a data grid with 50 rows. When a user taps one of the rows in the data grid, it opens another card where an image is displayed. When the user goes back to the card with the data grid, I want that card to open with the row that was just tapped, in view. For example, if the user taps on row 39 of the data grid, after viewing the image on the next card, I want row 39 to be in view when the comes back to the card with the data grid.

I am able to do this on the desktop version of LiveCode where I am building the app, however, when I test it on the iOS Simulator and my iPhone, when the card with the data grid is re-opened, the top rows of the data grid are displayed.

This is the code in the card script of the card that has the data grid:

Code: Select all

local gHilitedLine, pLine

on preOpenCard
 put the dgHilitedLine of group "DataGrid 1" into gHilitedLine
 
 put gHilitedLine into pLine
  
goToIndexedLine pLine

 end preOpenCard
 
 command goToIndexedLine pLine
   dispatch "ScrollLineIntoView" to group "DataGrid 1" with pLine
   set the dgHilitedLines of group "DataGrid 1" to pLine
end goToIndexedLine
 
I found "ScrollLineIntoView" in the dictionary because even when I had "set the dgHilitedLines of group "DataGrid 1" to gHilitedLine", it highlights the correct line, but it goes to the top of the data grid when the card is re-opened (in the simulator or iPhone).

Again, this code works perfectly fine on the desktop version of LiveCode where I'm building the app, but it doesn't work on the simulator or actual phone (e.g. if I tap row 39 on the simulator or the iPhone, when the card with the data grid is re-opened, it takes me to the top of the data grid, not lower where I can view row 39). Any thoughts?

Thanks,
Bellballer1

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: ScrollLineIntoView not working on iOS Simulator

Post by jacque » Tue Sep 21, 2021 4:38 pm

I think the first thing I'd do is to see if the dgHilitedLine has changed when returning to the card. Add an answer command temporarily to check:

Code: Select all

put the dgHilitedLine of group "DataGrid 1" into gHilitedLine
answer "Hilitedline:" && gHilitedLine -- add this 
Also, I don't see a need to have two local script variables with the same content, but that's a different thing.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

Re: ScrollLineIntoView not working on iOS Simulator

Post by Bellballer1 » Tue Sep 21, 2021 5:06 pm

Hi Jacque,

Thanks for the response.

The dgHilitedLine has not changed when returning to the card. The answer command that you suggested, proves that.

I only have an issue when I test on the iOS simulator and on my iPhone. I'm trying to figure out why the data grid returns to the top of the card on the simulator and iPhone, but works as it should on the desktop/build version. Thanks.

Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

Re: ScrollLineIntoView not working on iOS Simulator

Post by Bellballer1 » Thu Sep 23, 2021 2:56 am

I solved the problem I was having. The card needs to be open first. As I found in the LiveCode Lessons under Data Grids--"What sorts of things should I not do in order to avoid needless suffering?":

"When a Data Grid renders it dynamically creates fields and accesses certain properties. Some of these properties can not be properly reported by the Revolution engine unless the field is on an open card."

I knew there had to be a simple explanation as to why the data grid wasn't performing on the simulator and phone.

Bellballer1

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: ScrollLineIntoView not working on iOS Simulator

Post by jacque » Thu Sep 23, 2021 6:45 am

That's interesting, you'd think it would fail in the IDE too. But I'm glad you were able to solve it. So did you move the commands to the openCard handler?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

Re: ScrollLineIntoView not working on iOS Simulator

Post by Bellballer1 » Thu Sep 23, 2021 2:15 pm

Hi Jacque,

I did move the commands to the openCard handler. The fact that it was not failing in the IDE contributed to my "needless suffering."

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”