replay mouse press event after a popup widget has been closed
If a popup widget(e.g. a popup menu) has been closed due to a mouse press event, the mouse press event will be consumed by the popup widget and the widget under the mouse pointer can't receive the event. This will lead to confusing behavior such as a push button under the mouse pointer is not been push down. This patch replay the mouse press event if a popup widget has been closed. Change-Id: Id493583dfea9e64ab2964e28d559122c43bbc2a6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
9253509f3e
commit
a65157e5b7
@ -352,6 +352,21 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
||||
&& qt_replay_popup_mouse_event) {
|
||||
if (m_widget->windowType() != Qt::Popup)
|
||||
qt_button_down = 0;
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
// the popup disappeared, replay the mouse press event
|
||||
QWidget *w = QApplication::widgetAt(event->globalPos());
|
||||
if (w && !QApplicationPrivate::isBlockedByModal(w)) {
|
||||
QWindow *win = w->windowHandle();
|
||||
if (!win)
|
||||
win = w->nativeParentWidget()->windowHandle();
|
||||
if (win && win->geometry().contains(event->globalPos())) {
|
||||
const QPoint localPos = win->mapFromGlobal(event->globalPos());
|
||||
QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
|
||||
e.setTimestamp(event->timestamp());
|
||||
QApplication::sendSpontaneousEvent(win, &e);
|
||||
}
|
||||
}
|
||||
}
|
||||
qt_replay_popup_mouse_event = false;
|
||||
#ifndef QT_NO_CONTEXTMENU
|
||||
} else if (event->type() == QEvent::MouseButtonPress
|
||||
|
Loading…
Reference in New Issue
Block a user