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: John Hansen <email@hidden>
- Date: Wed, 10 Jul 2002 11:52:32 -0700
Greg and Tom,
Thanks for your replies. I almost have it working ( A subclass of
NSTextField that allows a path to be dropped on it ). It involves both a
subclass to NSTextField and a subclass to NSTextView. But I have run into
an unfortunate snag.
Subclassing NSTextView and using windowWillReturnFieldEditor in the window's
delegate to allow a Custom Field editor (of my subclass of NSTextView ) has
unwanted side effects.
Tabbing no longer advances to the next field.
Return and Enter scroll the text upwards instead of selecting all the text
as would happen in a normal text field item.
Any ideas?
JH
on 7/8/02 5:19 PM, Tom Waters at email@hidden wrote:
>
it's because there's another control overlapping the NSTextView... it's
>
the shared window editor.
>
>
look at windowWillReturnFieldEditor in your window's delegate.
>
on 7/8/02 5:40 PM, Greg Titus at email@hidden wrote:
>
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.
_______________________________________________
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.