chiark / gitweb /
Workaround for the issue when drag'n'drop to Cura's window does not work on Mac OS X.
authorIlya Kulakov <kulakov.ilya@gmail.com>
Tue, 18 Feb 2014 14:57:10 +0000 (21:57 +0700)
committerIlya Kulakov <kulakov.ilya@gmail.com>
Tue, 18 Feb 2014 14:57:10 +0000 (21:57 +0700)
Cura/gui/mainWindow.py

index e105056a770ce6d99d0cb31ec9b192111d6ca293..714fc8ea917fa226827a505ca3fefd15a476f22d 100644 (file)
@@ -3,6 +3,8 @@ __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AG
 import wx
 import os
 import webbrowser
+import sys
+
 
 from Cura.gui import configBase
 from Cura.gui import expertConfig
@@ -31,6 +33,14 @@ class mainWindow(wx.Frame):
                # allow dropping any file, restrict later
                self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles))
 
+               # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5
+               if sys.platform.startswith('darwin'):
+                       import Cocoa
+                       import objc
+                       nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef())
+                       view = nswindow.contentView()
+                       view.registerForDraggedTypes_([Cocoa.NSFilenamesPboardType])
+
                self.normalModeOnlyItems = []
 
                mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini')