Using Xojo under Kubuntu 22.04 I have the following question…
I use a text area for display various messages from the app to the user. Its handy because old messages are always here.
The new messages are appended to the existing text area text with a new line (chr(10)).
The text area is multiline and has a vertical scrollbar.
My problem is that each time I add a message the text area come back and display the first lines of the text… The new messages are at the bottom and I should use the scrollbar to see them.
I try to put a ‘Zon_dial.ScrollPosition = 100000’ into TextChange but without success.
So what can I do to have always the last lines of the text displayed ?
Setting it to the last line or beyond the last line will move the vertical scrollbar’s thumb to the bottom, not necessarily displaying the last line at the top of the control.
I dont want the last lines to the top of the text area.
I want that the 5-6 last lines of the text (depending of the text area height) be displayed with the last line at the bottom.
With ‘Zon_dial.VerticalScrollPosition = 100000’ (I have far less than 100000 lines into the text) the scrollbar dont go to the thumb bottom but to the middle.
In fact I expect that the text area work like a console screen…
Don’t do that. Use AddText as has been mentioned. Also use EndOfLine instead of chr(10).
You can also keep your own count of the number of lines in the textarea, and set the VerticalScrollPosition to a number a bit greater than that.
If you put all this into a method that you call to display a user message, you can simplify your code everywhere. You could also display coloured messges, too.
Using chr(10) or EndOfLine dont change anything.
If I add one line at a time with user action between this seems to work.
But as soon I add several messages (each one with a call to this routine) the scrollbar dont go to the bottom and stay at the middle.