How to make text scroll up with each new added line after reaching the bottom?

1,494 views
Skip to first unread message

Martin Vigesaa

unread,
Jul 26, 2014, 12:21:44 PM7/26/14
to mitappinv...@googlegroups.com
I have a text box which I am adding a new line with each button press.  Is there a way to make the text scroll upwards so the new lines are visible and the old lines scroll upwards After the text fills the size of the text box?   
Basically I want it to work  the same as notepad, Wordpad and Word...  if you continue typing at the bottom of the screen it begins to scroll so you can see what you are typing.
  

SteveJG

unread,
Jul 26, 2014, 1:46:36 PM7/26/14
to mitappinv...@googlegroups.com
OK... I got the idea.

Here are two ways.  On the Designer screen, for the textbox you use, just check in the Properties bin   Multiline.

However, I do not think that is what you want.   Notepad, Word etc. work well because you have a keyboard...a real keyboard, so what you want to do is awkward.

First, you do not want to use a textbox. to display the note. That is a control for typing in text.  You could use a label to make the display.    How?

Try something like this:
In your button,click event handler ... the one you press to add the text do this:

label1.text:= label1.text + textbox1.text  

a variation might be 

label1.text:= label1.text + textbox1.text  + \n\n    which might force a line feed.

or label1.text:= textbox1.text  +label1.text

Try some blocks, see what works for you.   If you are still in difficulty, post an image of your blocks (jpg or png) and an explanation of what the text should look like with an example.

Good luck,
Regards,
Steve

Martin Vigesaa

unread,
Jul 26, 2014, 3:01:44 PM7/26/14
to
Thanks for the ideas.
I think what you described is similar to what I had setup.  I'm trying to create a window for debug info that keeps scrolling so the new text doesn't disappear off the bottom AND the window doesn't auto grow as this would mean have to scroll down.  

Below is a screenshot of the display and blocks I have setup now.  I tried adding a label in addition to the text box to see if it would behave any better but in both cases the text scrolls off screen.  
As you can see after item 6, the data goes off text box and label area.  I would like to force it to auto scroll up as new items appear, preferably without deleting the old items. I also don't want to make the viewing area of the text box or label larger.    


SteveJG

unread,
Jul 26, 2014, 3:55:45 PM7/26/14
to mitappinv...@googlegroups.com
I can see the issue.  There is no simple solution.   If you just had a vertical arrangement, I think you would be fine but you have two text columns plus a button column.

If you just have a single 'column'  just use the Screen1 Properties bin and select Scrollable and you could used finger motions to read through your labels.  Since you put both 
text labels, into a Horizontal Arrangement, You can not do that.   Sorry, you can not have your cake and eat it.  AI2 does not have what in other compiler languages is called a Memo.

What you can have is have the most recent event post first, instead of at the bottom of the text column.  I thing one of the solutions I provided you will do that.  Some wacky work arounds:
decrease the text font from 14 to 10?      Use an html to report the information and use a WebViewer to view it (I am not sure how this could be done at the moment but think it is possible); another waky work around would be to post your info in a Canvas, with a larger height than the height of the Horizontal arrangement, then use the Canvas.DrawText tool...be careful here, you have to tell the canvas the line you want the comment posted on; subsequent additions need to be the y value of the DrawText  plus sufficient spacing.

Just more ideas.   Again, try some more blocks.... try a vertical arrangement or no arrangement at all and place the labels one over the other.  Not what you want but all that might be available.

Perhaps someone else will post with different ideas.


Try even more blocks. or graduate to one of the professional free compilers Eclipse or Android Studio ... both of which can do what you want to do.

Regards,
Steve

Scott Ferguson

unread,
Jul 26, 2014, 11:31:45 PM7/26/14
to mitappinv...@googlegroups.com
As SteveJG has suggested, perhaps inserting the next item at the top of the Label is the easiest solution.
After adding an item, follow it with the \n line feed code.
---
sf
Reply all
Reply to author
Forward
0 new messages