Auto Scrolling Field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Auto Scrolling Field
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.
Kind regards.
-
- VIP Livecode Opensource Backer
- Posts: 184
- Joined: Wed Apr 10, 2013 5:09 pm
Re: Auto Scrolling Field
Hi,
I'm not sure about automatic, but
should scroll the text down to the last line.
Andrew
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
Andrew
Re: Auto Scrolling Field
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)..
See the textHeight property (this is automatically updated when you change the textSize AND the fixedLineHeight is set to TRUE)..
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")
-
- VIP Livecode Opensource Backer
- Posts: 3990
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Auto Scrolling Field
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
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
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Auto Scrolling Field
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.
-
- VIP Livecode Opensource Backer
- Posts: 3990
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Auto Scrolling Field
Hi Mick,
Kind regards
Bernd
you should include Shao, she deserves a big thanks for all her support on this forum and this thread.Well gents
Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Auto Scrolling Field
Wut? I thought with the Sean thing, oh Jesus.
I am so sorry Shao. I didn't realize. >_<
I am so sorry Shao. I didn't realize. >_<
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Auto Scrolling Field
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.
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.
Code: Select all
Set The VScroll Of Field 1 To (The Effective TextHeight Of Field 1) * (The Number Of Lines In Field 1)
-
- VIP Livecode Opensource Backer
- Posts: 184
- Joined: Wed Apr 10, 2013 5:09 pm
Re: Auto Scrolling Field
Don't work? It worked for me in 6.1mickpitkin92 wrote:unfortunately the ones that Shaosean and Andrew suggested, don't work, at least not in 6.1 they don't.
Andrew
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Auto Scrolling Field
Doesn't work for some reason, not sure why.
-
- VIP Livecode Opensource Backer
- Posts: 184
- Joined: Wed Apr 10, 2013 5:09 pm
Re: Auto Scrolling Field
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
If that is the case then the code you found, or the idea by Bernd would be best.
Andrew
Re: Auto Scrolling Field
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:
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.
Code: Select all
on scrollMe
set the vScroll of field "myTextBox" to (the textHeightSum of field "myTextBox") - 100
end scrollMe
So, after every time I add text to myTextBox, I just run the command scrollMe, and that keeps everything looking like a console feed.