Proper sub-widget mouse grabbing in QWidgetWindow.
This commit is contained in:
parent
07fef33d28
commit
c418f5ce8d
@ -91,13 +91,19 @@ bool QWidgetWindow::event(QEvent *event)
|
||||
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
||||
{
|
||||
// which child should have it?
|
||||
QWidget *widget = m_widget->childAt(event->pos());
|
||||
QWidget *widget = m_implicit_mouse_grabber ? m_implicit_mouse_grabber.data() : m_widget->childAt(event->pos());
|
||||
|
||||
// TODO: make sure mouse release is delivered to same widget that got the press event
|
||||
|
||||
if (!widget)
|
||||
widget = m_widget;
|
||||
|
||||
if (event->type() == QEvent::MouseButtonPress && !m_implicit_mouse_grabber)
|
||||
m_implicit_mouse_grabber = widget;
|
||||
|
||||
if (event->buttons() == Qt::NoButton)
|
||||
m_implicit_mouse_grabber.clear();
|
||||
|
||||
QPoint mapped = widget->mapFrom(m_widget, event->pos());
|
||||
|
||||
QMouseEvent translated(event->type(), mapped, event->globalPos(), event->button(), event->buttons(), event->modifiers());
|
||||
|
@ -72,6 +72,7 @@ protected:
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QWeakPointer<QWidget> m_implicit_mouse_grabber;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user