Going to a line in a scrollable field

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Going to a line in a scrollable field

Post by scotttyang » Thu Sep 06, 2012 5:03 pm

On the Mac, if I do a "Find" command of a string, the field jumps to that line, but in iOS, in the simulator and the iPad, the foundline doesn't jump to the middle of the scrollable field....

Any solutions?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Going to a line in a scrollable field

Post by jmburnod » Fri Sep 07, 2012 1:45 pm

Hi scotttyang,

Maybe this script is useful for you (tested on simulator only):

Code: Select all

on shSearchInFld pSearch
   put the num of chars of pSearch into tNbC
   put trunc(the height of fld 1/2) into tH
   put fld 1 into tText
   put offset(pSearch,tText) into tOff
   put the formattedHeight of char 1 to tOff of field 1 into tFH
   set the scroll of fld 1 to tFH-tH
   select char tOff to tOff+ tnbc-1 of fld 1
end shSearchInFld
Best regards

Jean-Marc
https://alternatic.ch

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: Going to a line in a scrollable field

Post by scotttyang » Fri Sep 07, 2012 3:32 pm

Thanks! The concept generally works. The problem is, maybe it's a bug for me, as my scroll field is in a group, so I have to

set the scroll of group "grpscrollingfield" to 500

BUt when I scroll the field, it jumps back to its original scroll position prior to the "set the scroll of the group"

Doesn't make sense to me.

I may have to take this feature out of the App, until I figure it out...as the app is already at the AppStore waiting for review, and have a few more days to fix this...the jumping back to previous scroll point!

Scott

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: Going to a line in a scrollable field

Post by scotttyang » Fri Sep 07, 2012 3:56 pm

it does seem it is the ...

scrollerDidscroll pOffsetX,pOffsetY


that is resetting the scroll after finding a word in the field to the previous scroll position. .... not sure how to get around this...with the scrollerDidscroll, scroller doesn't work....hmmm...

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Going to a line in a scrollable field

Post by jmburnod » Fri Sep 07, 2012 4:05 pm

Can you post your stack, that will be to easy help you
https://alternatic.ch

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: Going to a line in a scrollable field

Post by scotttyang » Sat Sep 08, 2012 7:06 am

See the attached stack. It's basically a very basic scroll stack. Below are buttons A to H. Clicking on the Letter buttons cause the scroller to jump the the Letter, setting it to the top. BUT...........if you try to scroll again, it jumps the list to the previous vScroll. So it is a bit awkward...WIll need to use in the simulator
Attachments
scroller search.livecode.zip
finding string in ios scroller
(8.52 KiB) Downloaded 246 times

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Going to a line in a scrollable field

Post by jmburnod » Sat Sep 08, 2012 10:52 am

Hi,
The problem is in the "alphasearch" handler
put
   

Code: Select all

iphoneControlSet scrollid2, "vscroll", vS
instead

Code: Select all

 set the scroll of group "scrollgroup" to vS
and it work like you want
Best
Jean-Marc
https://alternatic.ch

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: Going to a line in a scrollable field

Post by scotttyang » Sun Sep 09, 2012 4:20 am

oh that did it! thanks! would not have figured that out easily myself!

Post Reply