]> git.saurik.com Git - wxWidgets.git/commitdiff
native drop target method for cocoa
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 1 Jul 2012 15:46:56 +0000 (15:46 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 1 Jul 2012 15:46:56 +0000 (15:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/private.h
src/osx/cocoa/window.mm

index 283e8ee64b05ee60a46482847d2294cf5bf67db7..dbaa1ece9fabd9af8f38d8b67919f8c11f612ed3 100644 (file)
@@ -105,6 +105,8 @@ public :
     void                CaptureMouse();
     void                ReleaseMouse();
 
+    void                SetDropTarget(wxDropTarget* target);
+    
     wxInt32             GetValue() const;
     void                SetValue( wxInt32 v );
     wxBitmap            GetBitmap() const;
index 1bebf436d2519760e561765441f7200d3478244e..46aa01527af1b1d4015f387ec18240b0dbf5abe8 100644 (file)
@@ -2072,6 +2072,23 @@ bool wxWidgetCocoaImpl::SetFocus()
     return true;
 }
 
+void wxWidgetCocoaImpl::SetDropTarget(wxDropTarget* target)
+{
+    [m_osxView unregisterDraggedTypes];
+    
+    if ( target == NULL )
+        return;
+    
+    wxDataObject* dobj = target->GetDataObject();
+    
+    if( dobj )
+    {
+        CFMutableArrayRef typesarray = CFArrayCreateMutable(kCFAllocatorDefault,0,&kCFTypeArrayCallBacks);
+        
+        [m_osxView registerForDraggedTypes:(NSArray*)typesarray];
+        CFRelease(typesarray);
+    }
+}
 
 void wxWidgetCocoaImpl::RemoveFromParent()
 {
@@ -2534,10 +2551,6 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSView* v = [[wxNSView alloc] initWithFrame:r];
 
-    // temporary hook for dnd
-    [v registerForDraggedTypes:[NSArray arrayWithObjects:
-        NSStringPboardType, NSFilenamesPboardType, (NSString*) kPasteboardTypeFileURLPromise, NSTIFFPboardType, NSPICTPboardType, NSPDFPboardType, nil]];
-
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v, false, true );
     return c;
 }