From 14de8214d64262a0667f636ecc44f5994c50515d Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 1 Jul 2012 15:46:56 +0000 Subject: [PATCH] native drop target method for cocoa git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/cocoa/private.h | 2 ++ src/osx/cocoa/window.mm | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 283e8ee64b..dbaa1ece9f 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -105,6 +105,8 @@ public : void CaptureMouse(); void ReleaseMouse(); + void SetDropTarget(wxDropTarget* target); + wxInt32 GetValue() const; void SetValue( wxInt32 v ); wxBitmap GetBitmap() const; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 1bebf436d2..46aa01527a 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -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; } -- 2.45.2