diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 57e60ac..2258ce6 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -980,6 +980,7 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) } else { d->control->processInputMethodEvent(ev); updateSize(); + d->updateHorizontalScroll(); } if (!ev->isAccepted()) QDeclarativePaintedItem::inputMethodEvent(ev); @@ -1098,7 +1099,8 @@ int QDeclarativeTextInputPrivate::calculateTextWidth() void QDeclarativeTextInputPrivate::updateHorizontalScroll() { Q_Q(QDeclarativeTextInput); - int cix = qRound(control->cursorToX()); + const int preeditLength = control->preeditAreaText().length(); + int cix = qRound(control->cursorToX(control->cursor() + preeditLength)); QRect br(q->boundingRect().toRect()); int widthUsed = calculateTextWidth(); Qt::Alignment va = QStyle::visualAlignment(control->layoutDirection(), QFlag(Qt::Alignment(hAlign))); @@ -1128,6 +1130,14 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll() // right hscroll = widthUsed - br.width() + 1; } + if (preeditLength > 0) { + // check to ensure long pre-edit text doesn't push the cursor + // off to the left + cix = qRound(control->cursorToX( + control->cursor() + qMax(0, control->preeditCursor() - 1))); + if (cix < hscroll) + hscroll = cix; + } } else { switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { case Qt::AlignRight: |