[SailfishDevel] Read-only TextArea: Always keep the lines added last visible

Dirk Zimmermann me at dirkz.com
Fri Jan 2 09:08:54 UTC 2015


On 02.01.2015 09:21, Андрей Кожевников wrote:
> 1. Why TextArea? Why not ListView + ListModel.

TextArea (or anything similar) gives me nice line wrap (some lines are
very long). If need I can also omit newlines and make even better use of
available space.

> 2. TextArea have own scroller, you dont need Flickable. Just try to use
> cursorPosition property or avoid using TextArea.

I tried cursorPosition before, doesn't work (see example below). On iOS,
I set the selection after the text and then scroll to that selection,
that keeps the view scrolled to the end. The strange thing is that on
sailfish I can't even scroll the text manually, do I have to enable
something?

Thanks for your input!

import QtQuick 2.0
import Sailfish.Silica 1.0

Page {
    id: textAreaLogExample

    TextArea {
        id: textAreaLog
        readOnly: true
        text: "Test"
    }

    Timer {
        interval: 500; running: true; repeat: true
        onTriggered: {
            textAreaLog.text += "\n" + new Date().getUTCSeconds() + "
Log " + textAreaLog.text.length
            textAreaLog.cursorPosition = textAreaLog.text.length - 1
        }
    }
}


More information about the Devel mailing list