diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-04-01 09:01:08 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-04-01 13:10:55 (GMT) |
commit | 3ab68cbf5436e3e66d0297b01af661bedecb8766 (patch) | |
tree | 853a597d8d6e8509f80b9749b3087cf0e5ea3089 /src/gui/kernel | |
parent | f3dbe7d3ebac51b32cf7cc227032fa87a087c682 (diff) | |
download | Qt-3ab68cbf5436e3e66d0297b01af661bedecb8766.zip Qt-3ab68cbf5436e3e66d0297b01af661bedecb8766.tar.gz Qt-3ab68cbf5436e3e66d0297b01af661bedecb8766.tar.bz2 |
Give input context focus only when widget is enabled.
When disabling a widget that accepts keyboard input we disable input
context by calling QInputContext::setFocusWidget(0).
Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c4224ed..8ede230 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2086,8 +2086,9 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) if(focus && QApplicationPrivate::focus_widget == focus) { if (focus->testAttribute(Qt::WA_InputMethodEnabled)) { QInputContext *qic = focus->inputContext(); - if (qic && focus_widget->testAttribute(Qt::WA_WState_Created)) - qic->setFocusWidget( focus_widget ); + if (qic && focus->testAttribute(Qt::WA_WState_Created) + && focus->isEnabled()) + qic->setFocusWidget(focus); } QFocusEvent in(QEvent::FocusIn, reason); QPointer<QWidget> that = focus; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index eb51024..61b4543 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2967,6 +2967,15 @@ void QWidgetPrivate::setEnabled_helper(bool enable) #if defined(Q_WS_MAC) setEnabled_helper_sys(enable); #endif + if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { + QInputContext *qic = inputContext(); + if (enable) { + qic->setFocusWidget(q); + } else { + qic->reset(); + qic->setFocusWidget(0); + } + } QEvent e(QEvent::EnabledChange); QApplication::sendEvent(q, &e); #ifdef QT3_SUPPORT @@ -9808,7 +9817,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); - if (ic) + if (ic && isEnabled()) ic->setFocusWidget(this); break; } @@ -9846,7 +9855,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) ic = d->inputContext(); } if (ic) { - if (on && hasFocus() && ic->focusWidget() != this) { + if (on && hasFocus() && ic->focusWidget() != this && isEnabled()) { ic->setFocusWidget(this); } else if (!on && ic->focusWidget() == this) { ic->reset(); |