Re: Drag&Drop woes...
Re: Drag&Drop woes...
- Subject: Re: Drag&Drop woes...
- From: daniel <email@hidden>
- Date: Wed, 16 Mar 2005 00:32:46 -0800
You may be missing something important about what "drag and drop" is...
it sounds from your description like you may be expecting a drag of a
filename over your application's window to automatically translate into
an "open this file" event. I assume you are making this prediction
based on your close mingling of the concepts of dragging an item to
your app's icon and dragging an item to your app's window. The two are
very different.
If you want to accept drags to a window or view, you not only have to
"registerForDragTypes" as you say you've done, but you then have to
implement a few dragging delegate methods to carry out the appropriate
feedback and ultimate operation of the drag in question. Dragging a
file to an app doesn't necessarily mean "open the file" - for instance
if you drag a file to a Mail application window it might mean "add this
file as an attachment."
If you are not yet at the point where you're looking at methods like
"draggingEntered:" then you need to go read up on that now. If you are
at that point, then you need to give some more specific information
about "nothing" happening. The first thing I would do is implement a
draggingEntered: method and NSLog something reassuring like "I could
accept a drag!" from that method.
Daniel
On Mar 16, 2005, at 12:01 AM, <email@hidden> wrote:
Okay, this is seriously starting to get frustrating. I have a window
with an NSTabView on it with 4 tabs. 3 of these tabs each have an
NSTextView in them among other controls. All I want to be able to do
is enable the user to drag files over the app (while it's running),
and have it add the filenames to the NSTextView (as well as set the
file(s) to an instance variable in the associated controller object
for that tab).
Now, I have set my application up so files can be dropped onto the app
icon (in the Finder or Dock) and have it set the file(s) to the
appropriate instance variable of the appropriate controller object
which also selects the appropriate tab and writes the filenames to the
NSTextView. This is all working fine and dandy. I simply have an
AppController set as NSApplication's delegate to use the openFiles:
method, and this all works fine.
But I cannot enable drag and drop while the application is running. I
tried subclassing NSTextView and added the appropriate code according
to several working examples I've found on the web. Nothing. I tried
using the actual window itself to accept drag and drop, nothing.
Thinking that the NSTabView is the view item in the forefront, I
subclassed the NSTabView, added the appropriate code, and nothing. I
drag files over the application while it's open and running, and the
files just slide back to the Finder window (or the Desktop if that's
where I'm dragging the files from).
Am I missing something? Is there something else I should be
subclassing and setting up to accept the dropping of files? This is
the last major addition to my small app, and I'm really wanting to get
it done so I can move on to other things. Thanks for any advice.
Yes, in each attempt I've called the registerForDragTypes: method in
both the init and awakeFromNib method (as I'd seen it called in both
places in different apps), and nothing.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden