diff options
-rw-r--r-- | src/gui/text/qlinecontrol.cpp | 28 | ||||
-rw-r--r-- | src/gui/text/qlinecontrol_p.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/text/qlinecontrol.cpp b/src/gui/text/qlinecontrol.cpp index 91a07d926e..62f4515fcc 100644 --- a/src/gui/text/qlinecontrol.cpp +++ b/src/gui/text/qlinecontrol.cpp @@ -151,6 +151,30 @@ void QLineControl::paste(QClipboard::Mode clipboardMode) /*! \internal + Exits preedit mode and commits parts marked as tentative commit +*/ +void QLineControl::commitPreedit() +{ + if (!composeMode()) + return; + + qApp->inputPanel()->reset(); + + if (!m_tentativeCommit.isEmpty()) { + internalInsert(m_tentativeCommit); + m_tentativeCommit.clear(); + finishChange(-1, true/*not used, not documented*/, false); + } + + m_preeditCursor = 0; + setPreeditArea(-1, QString()); + m_textLayout.clearAdditionalFormats(); + updateDisplayText(/*force*/ true); +} + +/*! + \internal + Handles the behavior for the backspace key or function. Removes the current selection if there is a selection, otherwise removes the character prior to the cursor position. @@ -243,6 +267,8 @@ void QLineControl::clear() */ void QLineControl::setSelection(int start, int length) { + commitPreedit(); + if(start < 0 || start > (int)m_text.length()){ qWarning("QLineControl::setSelection: Invalid start position"); return; @@ -403,6 +429,8 @@ bool QLineControl::fixup() // this function assumes that validate currently retu */ void QLineControl::moveCursor(int pos, bool mark) { + commitPreedit(); + if (pos != m_cursor) { separate(); if (m_maskData) diff --git a/src/gui/text/qlinecontrol_p.h b/src/gui/text/qlinecontrol_p.h index 7f5244ee07..4970a8c05e 100644 --- a/src/gui/text/qlinecontrol_p.h +++ b/src/gui/text/qlinecontrol_p.h @@ -209,6 +209,7 @@ public: QString text() const; QString realText() const; void setText(const QString &txt); + void commitPreedit(); QString displayText() const { return m_textLayout.text(); } |