Bug report #2793
Drag and Drop regression on Mac OSX
|Affected QGIS version:||Regression?:||No|
|Operating System:||OS X||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||fixed|
|Crashes QGIS or corrupts data:||Copied to github as #:||12853|
In QGIS 1.4 on osx it is possible to both:
1) Double click on one shapefile (with the .shp ext), have it open QGIS (if not previously open), and zooms to the layer's extent.
2) Double click or drag and drop a second shapefile and have it automatically added to the layers list
In QGIS trunk (r13595), only the #3905 above works. Double-clicking or dragging and dropping a second shapefile prompts no response.
While this may seems like a minor breakage in functionality, it is such a nice feature I've really come to depend on it, so +1 to keeping it working if possible.
#1 Updated by William Kyngesburye over 10 years ago
Further clarification from my use: double-click a shapefile or drag-n-drop a shapefile onto the Qgis icon works only if Qgis is not already running. If Qgis is running, even with an empty layout, one must drag the shapefile into the layers pane of the window. If running, a drag-n-drop or double-click will activate the Qgis application, so the system seems to be sending the open file event to Qgis.
I'm using Qt 4.6. I don't remember if I saw this with Qt 4.5.
#3 Updated by William Kyngesburye almost 10 years ago
It's now even worse - double-clicking or drag-n-drop onto QGIS do not work at all to open a GIS data file or a project file, not even if QGIS is not running. Though they still activate/start QGIS.
Dragging a data file (or a QGIS project file, odd) into the layers palette still works.
This is current SVN (f3738369 (SVN r15000)), with Qt 4.7.
#4 Updated by William Kyngesburye over 9 years ago
Hah! I found a reference in QApplication::macEventFilter, though not used in QGIS, that Mac events are handled differently in Qt Cocoa:
Cocoa uses a different event system which means this function is NOT CALLED when building Qt against Cocoa. If you want similar functionality subclass NSApplication and reimplement the sendEvent: message to handle all the NSEvents. You also will need to to instantiate your custom NSApplication before creating a QApplication. See Apple's NSApplication Reference for more information.
So, the openDocumentsAEHandler() setup in main.cpp may not be called using Qt Cocoa. This is way beyond me to try to fix.
#5 Updated by Tom Elwertowski over 9 years ago
- Status changed from Open to In Progress
Yes, a Cocoa vs. Carbon app is the cause of the problem.
I have been building both Qt/Carbon and Qt/Cocoa but using QGIS/Qt/Carbon because it works more reliably. I was still waiting for Qt/Cocoa to improve or for Qt to issue some instructions on what developers need to change.
While pursuing the details of NSApplication/QApplication interaction, I discovered QFileOpenEvent which reports "double clicking on a file icon in the Finder" among other things. It looks like it abstracts Carbon/Cocoa Open Document Apple Events so that separate code isn't needed for each.
Rather than writing Cocoa code to match the existing Carbon code, migrating to QFileOpenEvent may be a better solution.