home *** CD-ROM | disk | FTP | other *** search
-
- #import "DADTextField.h"
-
- @implementation DADTextField
-
- - initFrame:(const NXRect *)r
- {
- const char *WDRAG_PBTYPE[] = { NXFilenamePboardType, NULL};
-
-
- [super initFrame:r];
- [self registerForDraggedTypes:WDRAG_PBTYPE count:1];
-
- return self;
- }
-
- // the receptor gets sent this message when the object is dragged into
- // the File window, and when it is unarchived from the nib file.
- - awake
- {
- const char *WDRAG_PBTYPE[] = { NXFilenamePboardType, NULL};
-
-
- [super awake];
- [self registerForDraggedTypes:WDRAG_PBTYPE count:1];
-
- return self;
- }
-
-
-
- ////////////////////////////////////////////////////////////////////
- // Dragging stuff
- ///////////////////////////////////////////////////////////////////
-
-
- - (NXDragOperation)draggingEntered:(id <NXDraggingInfo>)sender
- {
- Pasteboard *pboard;
- const NXAtom *theType;
-
-
- pboard = [sender draggingPasteboard];
- theType = [pboard types];
-
- if (*theType != NXFilenamePboardType)
- { fprintf(stderr, "Right type: acknowledging dragging starting...\n");
- fflush(stderr);
- return NX_DragOperationCopy;
- }
- fprintf(stderr, "Wrong type: unable to acknowledge dragging starting.\n");
- fflush(stderr);
-
- return NX_DragOperationNone;
- }
-
- - (NXDragOperation)draggingUpdated:(id <NXDraggingInfo>)sender
- {
- return NX_DragOperationCopy;
- }
-
-
- - (BOOL)performDragOperation:(id <NXDraggingInfo>)sender
- {
- Pasteboard *pboard;
- char *argv;
- int len;
- const NXAtom *theType;
-
-
- pboard = [sender draggingPasteboard];
- theType = [pboard types];
-
- if (*theType != NXFilenamePboardType)
- { if ([pboard readType:NXFilenamePboardType data:&argv length:&len] == nil)
- { fprintf(stderr, "unable to read filename from pasteboard.\n"); fflush(stderr);
- return NO;
- }
- else
- { [self setStringValue:(const char *)argv];
- [self display];
- return YES;
- }
- }
- else
- { fprintf(stderr, "The type of the dragged object isn't a filename.\n"); fflush(stderr);
- return NO;
- }
- }
-
- @end
-