Page 1 of 1
Going to a line in a scrollable field
Posted: Thu Sep 06, 2012 5:03 pm
by scotttyang
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?
Re: Going to a line in a scrollable field
Posted: Fri Sep 07, 2012 1:45 pm
by jmburnod
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
Re: Going to a line in a scrollable field
Posted: Fri Sep 07, 2012 3:32 pm
by scotttyang
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
Re: Going to a line in a scrollable field
Posted: Fri Sep 07, 2012 3:56 pm
by scotttyang
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...
Re: Going to a line in a scrollable field
Posted: Fri Sep 07, 2012 4:05 pm
by jmburnod
Can you post your stack, that will be to easy help you
Re: Going to a line in a scrollable field
Posted: Sat Sep 08, 2012 7:06 am
by scotttyang
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
Re: Going to a line in a scrollable field
Posted: Sat Sep 08, 2012 10:52 am
by jmburnod
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
Re: Going to a line in a scrollable field
Posted: Sun Sep 09, 2012 4:20 am
by scotttyang
oh that did it! thanks! would not have figured that out easily myself!