diff options
author | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2011-10-04 17:44:35 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-05 23:47:02 +0100 |
commit | 7851568c65e0560056c6fa541039543d43a63e20 (patch) | |
tree | 75eef36925198b1e21d60ae1916b1cca8f634ee6 /src/widgets/widgets/qwidgetlinecontrol.cpp | |
parent | 10dc2171cf004705f8212f5100b99bfde04c8d54 (diff) |
QLineEdit - made mouse interactions commit preedit
Simplifying input context mouse handling rules by making
the editor in charge when text gets committed and selected.
This includes:
- Allowing selection to start on top of preedit. Commits once a
single character gets selected
- Double click to commit preedit before selecting a word.
- Only sending events to input context that happen on top of preedit.
- Committing preedit when a mouse press happens outside of it,
allowing to move cursor to click position.
Change-Id: I9dab00ea3445055ffd0d7cae540a1197c5748509
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets/widgets/qwidgetlinecontrol.cpp')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 498b972045..027512b6ae 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -167,6 +167,31 @@ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode) /*! \internal + Exits preedit mode and commits parts marked as tentative commit +*/ +void QWidgetLineControl::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. @@ -259,6 +284,8 @@ void QWidgetLineControl::clear() */ void QWidgetLineControl::setSelection(int start, int length) { + commitPreedit(); + if(start < 0 || start > (int)m_text.length()){ qWarning("QWidgetLineControl::setSelection: Invalid start position"); return; @@ -394,6 +421,8 @@ bool QWidgetLineControl::fixup() // this function assumes that validate currentl */ void QWidgetLineControl::moveCursor(int pos, bool mark) { + commitPreedit(); + if (pos != m_cursor) { separate(); if (m_maskData) |