Re: Drag and Drop file paths onto text field
Re: Drag and Drop file paths onto text field
- Subject: Re: Drag and Drop file paths onto text field
- From: Greg Titus <email@hidden>
- Date: Mon, 8 Jul 2002 17:40:53 -0700
I think you mean you are subclassing NSTextField instead of NSTextView,
right?
The behavior you are seeing is due to the way that NSTextFields handle
editing. They don't do any editing themselves, instead they use the
window's field editor, which is an instance of NSTextView. When you edit
a text field, the text field takes this other view and places it above
itself in the view hierarchy. From there on, you are interacting with
the field editor view instead of the text field, until you end editing.
Setting the selection on a text field implicitly starts editing it, and
it is the NSTextView that is displaying the I-beam cursor.
What you need to do, probably, is to make your NSTextField subclass
simply begin editing when you drag a file over it. Then subclass
NSTextView, and implement -performDragOperation: to pull the filename
off of the pasteboard, format it how you like, add it back to the
pasteboard as a string, and then call the superclass implementation.
This will let all of NSTextView's existing machinery for drag and drop
text do almost all of your work for you.
Hope this helps,
--Greg
On Monday, July 8, 2002, at 04:45 PM, John Hansen wrote:
I am trying to drag and drop files onto a subclass of NSTextView and
put the
path name of the file as the string value of the text field. Everything
works quite well except for where the mouse must be to perform a
successful
drag. It seems that drag and drop only works when the mouse is held on
the
border of the text cell.
I put in protocol methods draggingEntered and draggingExited and found a
very strange behavior. The draggingEntered routine gets called when the
mouse is on the border of the text cell. The draggingExitted routine
gets
called as I enter the interior of the text cell. It is as if the view
rectangle of the text field consists of a one pixel border around the
interior of the cell. Does anyone know why this is happening? Does it
have
something to do with the mouse location that Text fields do so they can
show
the I-beam cursor?
John Hansen
Symantec
_______________________________________________
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.
_______________________________________________
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.