Help - Newbie Drag And Drop Question (again)
Help - Newbie Drag And Drop Question (again)
- Subject: Help - Newbie Drag And Drop Question (again)
- From: Volker Bublitz <email@hidden>
- Date: Thu, 10 Oct 2002 21:49:01 +0200
hi there,
i asked this question in another mailing list but can't get a solution
to my problem.
i have a subclass of NSTextField called myTextField... i tried to do
the following:
1. on dragging filling the whole textField with lightGray
2. on performDraggingOperationg displaying the Path of the dragged file
or folder
problems
1. just the border is displayed in light grey
2. i can only drag a file when dragging it to the border of the
textField and NOT by
dragging it to the center
try-outs
1.+2. i changed the NIB-file's attributes of myTextField from
("Editable,Enabled,Selectable,Small")
to ("NOT Editable,Enabled,Selectable,Small")
=> leads to a solution to both points one and two... but can't display
anything...
1.+2. i changed the NIB-file's attributes of myTextField from
("Editable,Enabled,Selectable,Small")
to ("Editable,Enabled,Selectable,Small AND Rounded")
=> leads to a solution only of point 1
i wanted the textField to be free for "hand-typed" paths and dragged
paths of files and folders...
thanks so much (followed the code),
volker
-------
#import "myTextField.h"
@implementation myTextField
- (id)initWithCoder:(NSCoder *)coder
{
[super setImportsGraphics:YES];
if(self=[super initWithCoder:coder]){
[self registerForDraggedTypes:[NSArray arrayWithObjects:
NSFilenamesPboardType, nil]];
}
return self;
}
- (NSDragOperation)draggingEntered:(id)sender
{
[super draggingEntered:sender];
highlight=YES;
[self setNeedsDisplay:YES];
return NSDragOperationCopy;
}
- (NSDragOperation)draggingUpdated:(id)sender
{
[super draggingUpdated:sender];
return NSDragOperationCopy;
}
- (void)draggingExited:(id)sender
{
[super draggingExited:sender];
highlight=NO;
[self setNeedsDisplay:YES];
}
- (void)draggingEnded:(id)sender
{
[super draggingEnded:sender];
highlight=NO;
[self setNeedsDisplay:YES];
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
[super prepareForDragOperation:sender];
return YES;
}
- (BOOL)performDragOperation:(id)sender
{
[super performDragOperation:sender];
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
[self setObjectValue:files];
[nameField setObjectValue:files];
return YES;
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[super concludeDragOperation:sender];
highlight=NO;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];
if(highlight==YES) {
[[NSColor lightGrayColor] set];
[NSBezierPath fillRect:rect];
}
else {
[[NSColor whiteColor] set];
[NSBezierPath fillRect:rect];
}
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.