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>
This commit is contained in:
parent
e19292120b
commit
68dc5b90c0
@ -663,6 +663,15 @@ QAccessibleInterface *QWindow::accessibleRoot() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the QObject that will be the final receiver of events tied focus, such
|
||||||
|
as key events.
|
||||||
|
*/
|
||||||
|
QObject *QWindow::focusObject() const
|
||||||
|
{
|
||||||
|
return const_cast<QWindow *>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWindow::showMinimized()
|
void QWindow::showMinimized()
|
||||||
{
|
{
|
||||||
|
@ -196,6 +196,7 @@ public:
|
|||||||
void setScreen(QScreen *screen);
|
void setScreen(QScreen *screen);
|
||||||
|
|
||||||
virtual QAccessibleInterface *accessibleRoot() const;
|
virtual QAccessibleInterface *accessibleRoot() const;
|
||||||
|
virtual QObject *focusObject() const;
|
||||||
|
|
||||||
QPoint mapToGlobal(const QPoint &pos) const;
|
QPoint mapToGlobal(const QPoint &pos) const;
|
||||||
QPoint mapFromGlobal(const QPoint &pos) const;
|
QPoint mapFromGlobal(const QPoint &pos) const;
|
||||||
|
@ -67,6 +67,16 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *QWidgetWindow::focusObject() const
|
||||||
|
{
|
||||||
|
QWidget *widget = m_widget->focusWidget();
|
||||||
|
|
||||||
|
if (!widget)
|
||||||
|
widget = m_widget;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
bool QWidgetWindow::event(QEvent *event)
|
bool QWidgetWindow::event(QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
@ -287,12 +297,9 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
|
|||||||
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
|
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QWidget *widget = m_widget->focusWidget();
|
QObject *receiver = focusObject();
|
||||||
|
|
||||||
if (!widget)
|
QGuiApplication::sendSpontaneousEvent(receiver, event);
|
||||||
widget = m_widget;
|
|
||||||
|
|
||||||
QGuiApplication::sendSpontaneousEvent(widget, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWidgetWindow::updateGeometry()
|
void QWidgetWindow::updateGeometry()
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
QWidget *widget() const { return m_widget; }
|
QWidget *widget() const { return m_widget; }
|
||||||
QAccessibleInterface *accessibleRoot() const;
|
QAccessibleInterface *accessibleRoot() const;
|
||||||
|
|
||||||
|
QObject *focusObject() const;
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *);
|
bool event(QEvent *);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user