This is DragView.m in view mode; [Download] [Up]
#import "DragView.h" #import "Controller.h" #import <AppKit/AppKit.h> @implementation DragView - (void) awakeFromNib { epsIcon = [[NSImage imageNamed:@"docEps.tiff"] retain]; // The drag area (NSImageView) should not act as drop area. // it accepts as drop area of all image types by default [self unregisterDraggedTypes]; } // won't be the top Window if something is dragged - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { return YES; } - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent { return YES; } // The mouseDown is the simplest possible implementation. // The drag operation is invoked immediately, // if the application includes drop-sites itself or the image // should appear after a little mouse movement, the implementation // is a little bit more complicated // Thanks to Prof. Heinrich Giesen, Uni Koblenz, Germany - (void)mouseDown:(NSEvent *)theEvent { NSSize dragOffset = NSMakeSize(0.0, 0.0); NSPasteboard *pboard; NSPoint origin = [self convertPoint:[theEvent locationInWindow] fromView:nil]; origin.x -= 10.0; origin.y -= 10.0; pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self]; [pboard setPropertyList:[NSArray arrayWithObject:[[NSApp delegate] tellMeTheEpsFile]] forType:NSFilenamesPboardType]; [self dragImage:epsIcon at:origin offset:dragOffset event:theEvent pasteboard:pboard source:self slideBack:YES]; [[NSApp delegate] focusToTex]; return; } - (unsigned)draggingSourceOperationMaskForLocal:(BOOL)flag { return NSDragOperationGeneric | NSDragOperationCopy; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.