From: Bob Ippolito <bob@re...> - 2005-04-17 05:35:58
On Apr 17, 2005, at 1:13 AM, Matt Baker wrote:
> On Apr 16, 2005, at 8:32 PM, Bob Ippolito wrote:
>> On Apr 16, 2005, at 10:54 PM, Matt Baker wrote:
>>> I'm absolutely stumped. I've spent three days trying to make this
>>> work to no avail. Currently I have an NSImageView where I want to
>>> drop a file and get it's filepath out of the pasteboard accordingly.
>>> Currently the ONLY way for me to do this is to subclass NSImageView
>>> and implement my own "DragView" class in the appdelegate.py. I
>>> would much rather have the draggingEntered_, draggingUpdated_, etc
>>> methods declared in my appdelegate class because I need the file
>>> path to be loaded into the textbox next to it (for example). All
>>> the examples I've seen online put the methods in the appdelegate,
>>> but if I do this the dragging methods simply are called as their
>>> supposed to be upon a drag event. My brain is fried, so I hope
>>> someone more experienced has a clue!
>> NSApplication doesn't support drag and drop (NSView and NSWindow do),
>> so the application delegate doesn't really factor into this (unless
>> the application delegate is really a delegate for other objects too).
>> You might be able to implement the NSDraggingDestination informal
>> protocol from the *NSImageView's delegate*. Did you forget to
>> connect the delegate outlet?
> What exactly do you mean by forgetting to connect the delegate? I'm
> new to cocoa, although I've created an outlet in the appdelegate it
> doesn't seem to matter if it's connected or not. Basically I'm trying
> to emulate the examples I found here:
> I can't tell what's different in his code as opposed to mine o_0
It's not the code that's different, it's the nib file. Creating an
outlet in the app delegate is backwards. You want to connect the
delegate outlet of the NSImageView to the delegate object (in this
case, probably the same object that is the NSApplication's delegate).
You should go through some of Apple's Cocoa tutorials to learn the hows
and whys of Interface Builder.