diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-08-17 09:57:14 (GMT) |
---|---|---|
committer | Timo Turunen <timo.p.turunen@nokia.com> | 2011-08-30 07:02:15 (GMT) |
commit | 829f6e1cfedbfc3cb6826e331af7ad7c853351b8 (patch) | |
tree | 9a518bf308ab96400a002e11b35d6294e2209a48 /src/gui/inputmethod | |
parent | b6dbe0a064139a0c45e374f87518d71195965fb0 (diff) | |
download | Qt-829f6e1cfedbfc3cb6826e331af7ad7c853351b8.zip Qt-829f6e1cfedbfc3cb6826e331af7ad7c853351b8.tar.gz Qt-829f6e1cfedbfc3cb6826e331af7ad7c853351b8.tar.bz2 |
Symbian: Fix backspace on empty lines of multiline textedits
Backspace on empty lines of multiline textedits didn't work because
in Symbian the virtual keyboard only gets one block of text at a time,
and there is some internal optimization in FEP that if the document
is empty, backspace doesn't get generated. Fixed by faking document
lenght to be one in cases where it is actually zero, except for password
fields with hidden text, as an extra asterisk would be generated in
those cases. Typically password fields are not multiline so this
shouldn't be a problem.
Task-number: QTBUG-20444
Reviewed-by: Sami Merila
(cherry picked from commit a2709ef3f4410a1d1755e00353e6f969f8bb5613)
Reapplied after bad v4.7.4 merge
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 2202d3a..e22e27c 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -1089,7 +1089,18 @@ TInt QCoeFepInputContext::DocumentLengthForFep() const return 0; QVariant variant = w->inputMethodQuery(Qt::ImSurroundingText); - return variant.value<QString>().size() + m_preeditString.size(); + + int size = variant.value<QString>().size() + m_preeditString.size(); + + // To fix an issue with backspaces not being generated if document size is zero, + // fake document length to be at least one always, except when dealing with + // hidden text widgets, where this faking would generate extra asterisk. Since the + // primary use of hidden text widgets is password fields, they are unlikely to + // support multiple lines anyway. + if (size == 0 && !(m_textCapabilities & TCoeInputCapabilities::ESecretText)) + size = 1; + + return size; } TInt QCoeFepInputContext::DocumentMaximumLengthForFep() const @@ -1172,6 +1183,12 @@ void QCoeFepInputContext::GetEditorContentForFep(TDes& aEditorContent, TInt aDoc // FEP expects the preedit string to be part of the editor content, so let's mix it in. int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); text.insert(cursor, m_preeditString); + + // Add additional space to empty non-password text to compensate + // for the fake length we specified in DocumentLengthForFep(). + if (text.size() == 0 && !(m_textCapabilities & TCoeInputCapabilities::ESecretText)) + text += QChar(0x20); + aEditorContent.Copy(qt_QString2TPtrC(text.mid(aDocumentPosition, aLengthToRetrieve))); } |