Added text drops to MaxGui (Mac)

BlitzMax Forums/BlitzMax Module Tweaks/Added text drops to MaxGui (Mac)

pls(Posted 2006) [#1]
I need text drops, and MaxGui only implemented file drops, so I added it to /brl.mod/cocoa.maxgui.mod/cocoa.macos.m:


in method:
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender

i added:
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
	NSPasteboard *pboard = [sender draggingPasteboard];
	if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
		NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
		int numberOfFiles = [files count];
		// Perform operation using the list of files
		// printf("windowview got drag\n");fflush(stdout);
		int i;
		for (i=0;i<numberOfFiles;i++)
		{
			BBString *name=bbStringFromNSString([files objectAtIndex:i]);
			brl_cocoamaxgui_PostCocoaGuiEvent( BBEVENT_WINDOWACCEPT,self,0,0,0,0,(BBObject*)name );
		}
		
	}
	//-------------------- pls@...-----------------------
	// add support for text drops...
	if( [[pboard types] containsObject:NSStringPboardType] ) {
		NSString *string=[pboard stringForType:NSStringPboardType];
		BBString *name=bbStringFromNSString(string);
		brl_cocoamaxgui_PostCocoaGuiEvent( BBEVENT_WINDOWACCEPT,self,0,0,0,0,(BBObject*)name );
	}
	//--------------------------------------------------------
	return YES;
}



and on line (aprox)1541 i added:

		if (style&WINDOW_ACCEPTFILES){
			[window registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
			//-------------------- pls@...-----------------------
			// add support for text drops...
			[window registerForDraggedTypes:[NSArray arrayWithObject:NSStringPboardType]];
			//--------------------------------------------------------
		}


hopefully this does not break something else, and it's working fine here...

PLS