diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2016-01-21 11:40:18 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-07 22:08:23 +0000 |
commit | 25555238cde42daf5a73669234e737c90ef9ea5f (patch) | |
tree | 2a115df55d0923fc5f74bd951b5ab893f0c2011c /src/quick/items/qquickwindow.cpp | |
parent | 1ecefb43f250374a598bc64e8ff3d3af2aac006c (diff) |
Fix copied QDragMoveEvent drop action to propagate to original event
Trying to set the drop action and the accepted state in a overridden
dragMoveEvent handler, does not get propagated to the original
QDragMoveEvent, because the event passed to the handler is a copy.
This does not allow canceling the drop action in the move handler,
or change the proposed action to a different one. Changing these
values in the move handler is important to allow modifying the cursor
when moving / hovering above a possible drop item, depending on
user conditions.
Fix consists in copying the drop action and accepted values to the
original event, as well as removing the hard-coded setAccepted
(true) call.
Task-number: QTBUG-58260
Change-Id: I7a4bd4e68ee1023a36a63d3e835c282077e4187c
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 340683f6c3..e6245f90f3 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2397,7 +2397,6 @@ void QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QEvent *e } else for (; grabItem != grabber->end(); grabItem = grabber->release(grabItem)) { QDragMoveEvent *moveEvent = static_cast<QDragMoveEvent *>(event); if (deliverDragEvent(grabber, **grabItem, moveEvent)) { - moveEvent->setAccepted(true); for (++grabItem; grabItem != grabber->end();) { QPointF p = (**grabItem)->mapFromScene(moveEvent->pos()); if ((**grabItem)->contains(p)) { @@ -2472,7 +2471,10 @@ bool QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QQuickIte event->keyboardModifiers(), event->type()); QQuickDropEventEx::copyActions(&translatedEvent, *event); + translatedEvent.setAccepted(event->isAccepted()); QCoreApplication::sendEvent(item, &translatedEvent); + event->setAccepted(translatedEvent.isAccepted()); + event->setDropAction(translatedEvent.dropAction()); if (event->type() == QEvent::DragEnter) { if (translatedEvent.isAccepted()) { grabber->grab(item); |