Relay focus in/out events to the offscreen QQuickWindow, and also
make the offscreen window believe it has the focus when the
render window has it.
Task-number: QTBUG-39033
Change-Id: Ib50b134e635833ad3813693ca272f04607c525b8
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
touchEvent->setTouchPoints(touchPoints);
}
+
+static inline bool windowHasFocus(QQuickWindow *win)
+{
+ const QWindow *focusWindow = QGuiApplication::focusWindow();
+ return win == focusWindow || QQuickRenderControl::renderWindowFor(win) == focusWindow;
+}
+
/*!
Set the focus inside \a scope to be \a item.
If the scope contains the active focus item, it will be changed to \a item.
}
if (!(options & DontChangeFocusProperty)) {
- if (item != contentItem || QGuiApplication::focusWindow() == q) {
+ if (item != contentItem || windowHasFocus(q)) {
itemPrivate->focus = true;
changed << item;
}
}
#endif
+
+void QQuickWidget::focusInEvent(QFocusEvent * event)
+{
+ Q_D(QQuickWidget);
+ d->offscreenWindow->focusInEvent(event);
+}
+
+void QQuickWidget::focusOutEvent(QFocusEvent * event)
+{
+ Q_D(QQuickWidget);
+ d->offscreenWindow->focusOutEvent(event);
+}
+
+
/*! \reimp */
bool QQuickWidget::event(QEvent *e)
{
virtual void showEvent(QShowEvent *);
virtual void hideEvent(QHideEvent *);
+ virtual void focusInEvent(QFocusEvent * event);
+ virtual void focusOutEvent(QFocusEvent * event);
+
#ifndef QT_NO_WHEELEVENT
virtual void wheelEvent(QWheelEvent *);
#endif