Page 1 of 1
Auto Scrolling Field
Posted: Sat Aug 03, 2013 10:33 am
by SirWobbyTheFirst
Now I hate to ask this because it is probably one of the basics, but is there anyway I can make a field automatically scroll down to show a new line when it is full? Effectively, something like booting OS X in Single User Mode and seeing each action the OS does as it is starting up.
Kind regards.
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 10:53 am
by andrewferguson
Hi,
I'm not sure about automatic, but
Code: Select all
--in this example the field is called "field", and the size of each line is 50 pixels
set the vScroll of field "field" to the number of lines of field "field" * 50
should scroll the text down to the last line.
Andrew
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 11:38 am
by shaosean
If you set the
fixedLineHeight property to TRUE and set the
textSize property to a font size you like, you can use the above code without hardcoding a value (the 50 in the code above)..
Code: Select all
--in this example the field is called "field"
set the vScroll of field "field" to the number of lines of field "field" * (the textHeight of field "field")
See the
textHeight property (this is automatically updated when you change the textSize AND the fixedLineHeight is set to TRUE)..
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 11:53 am
by bn
Hi Mick,
what I do if I want a scrolling text field to scroll to the bottom is to set the vScroll of the textfield to a ridiciously high number like 100000. Lazy but works.
This will scroll to the last line.
Kind regards
Bernd
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 1:36 pm
by SirWobbyTheFirst
Well gents, these are all fantastic ideas, in terms of making it automatic, writing to the field will be implemented as a function anyways and so the automatic stuff will be handled by the function anyways. I'll let you know which is best when I get a chance.
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 1:50 pm
by bn
Hi Mick,
Well gents
you should include Shao, she deserves a big thanks for all her support on this forum and this thread.
Kind regards
Bernd
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 2:05 pm
by SirWobbyTheFirst
Wut? I thought with the Sean thing, oh Jesus.
I am so sorry Shao. I didn't realize. >_<
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 6:58 pm
by SirWobbyTheFirst
So guys, I had a little try of this just now and unfortunately the ones that Shaosean and Andrew suggested, don't work, at least not in 6.1 they don't. Luckily enough, I stumbled upon a little gem in the hints section of the Dictionary for VScroll.
Code: Select all
Set The VScroll Of Field 1 To (The Effective TextHeight Of Field 1) * (The Number Of Lines In Field 1)
Thanks go to
kspieldenner@lifetouch.com who posted it back in 2010, nonetheless, when I get round to the contributors list, you three shall find yourselves on the list, along with a huge amount of other people who have helped me over the years. I just need to get round to finishing my software.

Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 7:48 pm
by andrewferguson
mickpitkin92 wrote:unfortunately the ones that Shaosean and Andrew suggested, don't work, at least not in 6.1 they don't.
Don't work? It worked for me in 6.1
Andrew
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 8:06 pm
by SirWobbyTheFirst
Doesn't work for some reason, not sure why.
Re: Auto Scrolling Field
Posted: Sat Aug 03, 2013 8:34 pm
by andrewferguson
Maybe it is not working because you have text that is wrapped to make it look like more than one line but actually is only a small number of lines.
If that is the case then the code you found, or the idea by Bernd would be best.
Andrew
Re: Auto Scrolling Field
Posted: Mon Jul 10, 2017 9:12 pm
by KurtR
Newbie here... This thread helped me solve a scrolling problem, but I found a tweak that makes this a little simpler. You can use the textHeightSum property of a field to determine its height/size, then just subtract from that to set the scroll position where you want. So no tracking or calculation of numbers of rows, etc. Here is an example:
Code: Select all
on scrollMe
set the vScroll of field "myTextBox" to (the textHeightSum of field "myTextBox") - 100
end scrollMe
In this example, I am using a font size of 12, and I experimented to find that 100 was the right number of pixels to subtract (or close to that). I use parenthesis for code clarity only, probably not needed. This custom handler positions the scroll at the last line of text. With other font sizes you might need a larger number of pixels to subtract. Anyway, I like the elegance of this approach, and use it a lot to create the look of a console feed in a field.
So, after every time I add text to myTextBox, I just run the command scrollMe, and that keeps everything looking like a console feed.