application:openFile problems

redbird

Registered
I'm trying to be able to drag and drop files onto my application, but it's not working and I don't know what I have set wrong.

I created a regular Cocoa application and am now trying to add this feature and can't.

In IB, I open MainMenu.nib and connect the File Object to my controller that I want to be the delegate via the delegate outlet. Then, in my controller, I add code for the function application:eek:penFile:. So, seems like everything should work, but when I build I can't drop files onto the icon.

Any ideas of what might be going on. I'm really hitting my head against the wall on this one and can't seem to figure it out. It's probably some minor detail I'm missing.

FYI, I've tried the following things (which probably seem silly in light of the right answer):

- Cleaning all targets and building from scratch
- putting [NSApp setDelegate: self] in init for my controller
- putting the method definition for application:eek:penFile in my header file

Probably some other things I've forgotten playing with the build settings. Any ideas? Thanks
 

serving2masters

Registered
Does your app not light up when you drag stuff over it, or does it just fail to open them?

If it doesn't even light up, make sure you have the target's "application settings"/"document types" filled out with all the things you want to be able to open - I'm pretty sure that's where the OS gets the info from as to what you can open. Just a guess though.
 

redbird

Registered
Originally posted by serving2masters
Does your app not light up when you drag stuff over it, or does it just fail to open them?

If it doesn't even light up, make sure you have the target's "application settings"/"document types" filled out with all the things you want to be able to open - I'm pretty sure that's where the OS gets the info from as to what you can open. Just a guess though.

It does not light up. If it did then at least I'd have something to go on.

I've tried playing with that, but got nowhere. I want my program to open any file, though, so setting it to a certain filetype is not really what I want. At any rate, it doesn't do anything. :-/
 

seb2

Registered
you did set the document types your app handles in target > application settings > document types so that the finder knows your app can handle them?
 

serving2masters

Registered
Okay, here's what you do:

In the targets's "appication settings"/Document types, create one with "*" as the extension and make sure to set the Document class to the file you want to open it. Then it will let you open everything.
 

redbird

Registered
Originally posted by serving2masters
Okay, here's what you do:

In the targets's "appication settings"/Document types, create one with "*" as the extension and make sure to set the Document class to the file you want to open it. Then it will let you open everything.

Okay, I tried this and it still didn't work. Here's how I have things set:

Name: NSStringPboardType
Extensions: "*"
OS Types: "****"
Icon file:
Document Class: RRR_Controller
Viewer

My application has only one window and not multiple windows, so there is no document class, only my controller. My controller reads in a text file, parses it, and displayes it.

I took some of these settings from DropScript, but they don't seem to work for me. (the only differences is that mine is a Viewer and has the Document Class set, which DropScript does not).
 

blb

`'
This may or may not be the case still, but under 10.1 (the last time I added drag/drop to a project), I had to force-restart Finder, as it seems to cache some of this info (as well as the icon).
 

redbird

Registered
Originally posted by blb
This may or may not be the case still, but under 10.1 (the last time I added drag/drop to a project), I had to force-restart Finder, as it seems to cache some of this info (as well as the icon).

Thanks, this was just the hint I needed. At first restarting the Finder didn't have any effect. Then I made a copy of the application, remembering I had a problem like this when I first built DropScript back a while ago, and everything suddendly started working with the copy. :) Seems it was just a Finder bug.
 
Top