OK this seems to work :-)
//gets the cn1 log, putz it in a text area and scroll it on if needed, in a
timer that runs every 500ms
private void updateLog()
{
new UITimer(new Runnable() {
public void run()
{
//we want a timer that constantly updates the log
gui_textAreaLog.setText( Tools.getLog());
//scroll it on
int cursorY = gui_textAreaLog.getLines()+1;
com.codename1.ui.Font textFont =
gui_textAreaLog.getStyle().getFont();
int rowsGap = gui_textAreaLog.getRowsGap();
int lineHeight = textFont.getHeight() + rowsGap;
gui_textAreaLog.scrollRectToVisible(gui_textAreaLog.getScrollX(), cursorY
* lineHeight, gui_textAreaLog.getWidth(), lineHeight, gui_textAreaLog);
}
}).schedule(500, true, this);//repeats
}
On Friday, July 7, 2017 at 2:02:56 AM UTC+8, Gareth Murfin wrote:
>
> This has been asked a lot but I dont think anyone ever got a solution, I
> have spent literally 30 minutes trying to get scrollRectToVisible to work
> once and for all and forget about this, but it still will not work. Could
> anyone give me some example code which will simply scroll a text area to
> the bottom? Sick to death of this issue to be honest I have been trying to
> do it for literally years and I always give up.
>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/851e38ed-60b4-4b21-90cd-5cc7a676c82d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.