Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
5.12
-
None
-
macOS 10.15.7
Qt 5.15.2
-
-
4332cb3134 (qt/qtbase/dev) 4332cb3134 (qt/tqtc-qtbase/dev), 7740ac36d (dev), c39a944e7 (6.9), 155e81418 (6.8)
Description
On macOS drag action to file manager (Desktop or Finder) does not switch between copy and move via Command key. It used to work in Qt4 and stopped working in Qt5.
To reproduce:
1. Clone draggabletext example and add two lines to set mime urls:
--- dragwidget-orig.cpp 2021-12-27 15:01:07.620073838 +0200 +++ dragwidget.cpp 2021-12-27 15:01:37.427875858 +0200 @@ -159,6 +159,8 @@ void DragWidget::mousePressEvent(QMouseE mimeData->setText(child->text()); mimeData->setData(hotSpotMimeDataKey(), QByteArray::number(hotSpot.x()) + ' ' + QByteArray::number(hotSpot.y())); + if (child->text().startsWith("file:///")) + mimeData->setUrls(QList<QUrl>() << QUrl(child->text())); qreal dpr = window()->windowHandle()->devicePixelRatio(); QPixmap pixmap(child->size() * dpr);
2. Build and run the app.
3. Drag any file (file path should not contain whitespace) from Finder to the main window. A new file:///path/to/file.txt label will appear.
4. Create a new directory in Finder.
5. Drag file:///path/to/file.txt label to that new directory but do not release the mouse. Try holding/releasing Command key on the keyboard.
Expected behavior:
Mouse cursor should change between normal pointer and pointer with a green circle with a plus sign. Accordingly, when mouse released, the file should be moved or copied to the new location.
Actual behavior:
Mouse cursor does not change. File is always moved.
Same code works on Linux as expected. I can switch between copy and move action by holding a Ctrl key.
Attachments
Issue Links
- resulted in
-
QTBUG-132091 macOS: Key modifiers aren't ignored when dragging 'within the application'
- Closed