import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
Window {
visible: true
width: 400
height: 200
TextArea {
id: chat
anchors.fill: parent
property int threshold: 10
text: "Current\ntext\n\\to\nmove\ndown\ndown\ndown
\ndown\ndown\ndown\ndown\ndown\ndown\ndown"
Component.onCompleted: cursorPosition = text.length
flickableItem.onContentYChanged: {
if(flickableItem.contentY <= threshold) {
var oldHeight = flickableItem.contentHeight
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua." + text
flickableItem.contentY = threshold + flickableItem.contentHeight - oldHeight // leave flickable in old position
}
}
}
}