diff options
author | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-27 08:28:12 (GMT) |
---|---|---|
committer | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-27 08:28:12 (GMT) |
commit | fde5a9bde254dd0381762e2c52c0f4904599d40a (patch) | |
tree | 8b9f678c2bdc38f1c1c63daa97a3d2e17ea9ecda /src/gui | |
parent | 4c06cd950d27ba10d2288d508cbaef4e44abee91 (diff) | |
download | Qt-fde5a9bde254dd0381762e2c52c0f4904599d40a.zip Qt-fde5a9bde254dd0381762e2c52c0f4904599d40a.tar.gz Qt-fde5a9bde254dd0381762e2c52c0f4904599d40a.tar.bz2 |
Enabling QTextEdit to handle Input Methods.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit_p.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 1c4df93..c1ec5c2 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -74,6 +74,10 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_TEXTEDIT +static inline bool shouldEnableInputMethod(QTextEdit *textedit) +{ + return !textedit->isReadOnly(); +} class QTextEditControl : public QTextControl { @@ -104,7 +108,7 @@ public: QTextEditPrivate::QTextEditPrivate() : control(0), autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false), - lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), + lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), clickCausedFocus(0), wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), textFormat(Qt::AutoText) { ignoreAutomaticScrollbarAdjustment = false; @@ -1559,6 +1563,12 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e) d->autoScrollTimer.stop(); ensureCursorVisible(); } + if (e->button() == Qt::LeftButton && qApp->autoSipEnabled() + && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) { + QEvent event(QEvent::RequestSoftwareInputPanel); + QApplication::sendEvent(this, &event); + } + d->clickCausedFocus = 0; } /*! \reimp @@ -1694,6 +1704,9 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const void QTextEdit::focusInEvent(QFocusEvent *e) { Q_D(QTextEdit); + if (e->reason() == Qt::MouseFocusReason) { + d->clickCausedFocus = 1; + } QAbstractScrollArea::focusInEvent(e); d->sendControlEvent(e); } @@ -2058,7 +2071,7 @@ void QTextEdit::setReadOnly(bool ro) } else { flags = Qt::TextEditorInteraction; } - setAttribute(Qt::WA_InputMethodEnabled, !ro); + setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); d->control->setTextInteractionFlags(flags); } diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h index 3c37868..594174a 100644 --- a/src/gui/widgets/qtextedit_p.h +++ b/src/gui/widgets/qtextedit_p.h @@ -123,6 +123,7 @@ public: uint preferRichText : 1; uint showCursorOnInitialShow : 1; uint inDrag : 1; + uint clickCausedFocus : 1; // Qt3 COMPAT only, for setText Qt::TextFormat textFormat; |