[SailfishDevel] Read-only TextArea: Always keep the lines added last visible
Sami Kananoja
sami.kananoja at jolla.com
Wed Jan 7 11:06:32 UTC 2015
Hi,
This should do the trick:
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: textAreaLog.height
contentY: Math.max(0, contentHeight - height)
TextArea {
id: textAreaLog
readOnly: true
text: "Test"
width: flickable.width
}
}
The contentY binding is the one that keeps the last line visible (but has some annoying side effects if you want to scroll the content manually - fixing that is left as home work :) )
---
Sami Kananoja
________________________________________
From: devel-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] on behalf of Dirk Zimmermann [me+sailfishos at dirkz.com]
Sent: Friday, January 02, 2015 9:58 AM
To: devel at lists.sailfishos.org
Subject: [SailfishDevel] Read-only TextArea: Always keep the lines added last visible
Hi all,
I was trying to use a TextArea as a UI-visible debug log, so I can see
connection error details while I'm out using my app. The basic principle
is that the python code (pyotherside) will make a server request and
send detailed answers to the text area, which displays them. Everything
works find, except the text area doesn't auto scroll to the end when
there is more content than fits on the page. autoScrollenabled seems to
mean something entirely different, selectionStart start seems to be
read-only. I have put up an example that demonstrates, at the end of the
mail.
Does anyone know of the magic incantations needed to make sure the
latest lines are always visible?
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: textAreaLogExample
SilicaFlickable {
TextArea {
id: textAreaLog
readOnly: true
text: "Test"
autoScrollEnabled: true
}
}
Timer {
interval: 500; running: true; repeat: true
onTriggered: {
textAreaLog.text += "\n" + new Date().getUTCSeconds() + " Log"
}
}
}
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
More information about the Devel
mailing list