[futurebasic] Re: [FB] Drag and Drop - Problem with Drag Track Proc

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2010 : Group Archive : Group : All Groups

From: Rich Love <carnationsoftware@...>
Date: Thu, 16 Dec 2010 11:41:05 -0600
It works very nicely.
But not sure if I can figure out how to make it work in my app.

Rich


On Dec 16, 2010, at 10:59 AM, Bernie wrote:

> 
> This may work nicely if someone can adapt it to work with one of those HICocoaView thingies.
> 
> '---------------
> include "ConsoleWindow"
> window _FBConsoleWndNum,, (0,50)-(800,250)
> 
> toolbox fn NSApplicationLoad = Boolean
> fn NSApplicationLoad()
> 
> BeginCDeclaration
> typedef void (*CallbackType)(CFArrayRef);
> 
> @interface DragDropView : NSView {
> CallbackType callback;
> }
> @end
> 
> @implementation DragDropView
> - (id)initWithFrame:(NSRect)frame andCallback:(CallbackType)cb {
>    self = [super initWithFrame:frame];
>    if (self) {
>  [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
>  callback = cb;
>    }
>    return self;
> }
> 
> - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
>    NSPasteboard *pboard = [sender draggingPasteboard];
>    if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
>  return NSDragOperationLink;  
>    }
>    return NSDragOperationNone; 
> }
> 
> - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
> [[NSCursor arrowCursor] set];
>    NSPasteboard *pboard = [sender draggingPasteboard];
> if ([[pboard types] containsObject:NSFilenamesPboardType]) {
>  NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
>  (*callback)((CFArrayRef)files);
>  [self draggingExited:sender];
>  return YES;
>    }
>    return NO;
> }
> @end
> 
> void BuildDragDropWindow( void *callback )
> {
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> NSRect r = NSMakeRect( 450.0, 500.0, 300.0, 200.0 );
> NSWindow *window = [[NSWindow alloc] initWithContentRect:r styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES];
> [window setTitle:@"DragDrop"];
> DragDropView *ddView = [[DragDropView alloc] initWithFrame:NSMakeRect( 0.0, 0.0, r.size.width, r.size.height ) andCallback:callback];
> [[window contentView] addSubview:ddView];
> [window makeKeyAndOrderFront:nil];
> [pool drain];
> }
> EndC
> toolbox BuildDragDropWindow( ptr callback )
> 
> local fn ConsoleCFPrint( typeRef as CFTypeRef )
> '~'1
> dim as CFStringRef   oldText, newText
> 
> oldText = fn HIViewCopyText( sConsoleHITextView )
> newText = fn CFStringCreateWithFormat( _kCFAllocatorDefault, #0, @"%@%@", oldText, typeRef )
> CFRelease( oldText )
> fn HIViewSetText( sConsoleHITextView, newText )
> CFRelease( newText )
> end fn
> 
> local fn MyDragDropCallback( array as CFArrayRef )
> '~'1
> dim as CFIndex count, index
> 
> count = fn CFArrayGetCount( array )
> long if ( count )
> for index = 0 to count - 1
> fn ConsoleCFPrint( fn CFArrayGetValueAtIndex( array, index ) )
> next index
> end if
> end fn
> 
> BuildDragDropWindow( @fn MyDragDropCallback )
> '---------------
> 
> Bernie
> 
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> 


Rich Love - Carnation Software
Get 'Say it & Mail it' for iPhone
http://www.SayitMailit.com

MacWise Terminal emulation for Macintosh
http://www.CarnationSoftware.com
Twitter - http://twitter.com/CarnationSW
Email - RichLove@...
512 858-9234
















Attachments: