diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-10-21 10:59:27 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-22 19:18:20 +0200 |
commit | 68dc5b90c04058ff8d940c093528effa80ac7e4a (patch) | |
tree | 5b811142be4fa460885c141baa31f2515c7e4857 /src/widgets/kernel/qwidgetwindow_qpa.cpp | |
parent | e19292120b33f55a10f233bdaab7030f4299db66 (diff) |
Add virtual QWindow::focusObject() method
The method allows to retrieve the object that currently
has the input focus inside the Window. This is e.g.
required to correctly determine the context for keyboard
shortcuts.
Change-Id: I9e05ef62717973bac275ce34cc70fb86aa2d1e5b
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow_qpa.cpp')
-rw-r--r-- | src/widgets/kernel/qwidgetwindow_qpa.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 2265fb55fb..32a446fa54 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -67,6 +67,16 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const return 0; } +QObject *QWidgetWindow::focusObject() const +{ + QWidget *widget = m_widget->focusWidget(); + + if (!widget) + widget = m_widget; + + return widget; +} + bool QWidgetWindow::event(QEvent *event) { switch (event->type()) { @@ -287,12 +297,9 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event) if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) return; - QWidget *widget = m_widget->focusWidget(); - - if (!widget) - widget = m_widget; + QObject *receiver = focusObject(); - QGuiApplication::sendSpontaneousEvent(widget, event); + QGuiApplication::sendSpontaneousEvent(receiver, event); } void QWidgetWindow::updateGeometry() |