Drag and Drop with multiple script objects

I’ve been working on trying to get drag and drop working with my ASOC project. (i’m very new to ASOC) Ideally I was trying to make the entire interface accept the drag and drop, but I wasn’t having much success with it. In doing a lot of searching I eventually found an example that shows creating a new class in a separate script object, using a box object that you then assign this new class to to allow it to accept the drag and drop. My real question here now is, if i take this approach, how can I access the file paths dropped back in my main script?

In my new “boxDelegate” script, I tried to add a property…

	property theFiles : missing value

I call a new handler (in my main script) from the boxDelegate script


on concludeDragOperation_(sender)
     log "concludeDragOperation_"        
     appDelegate's storePaths_(theFiles)
end concludeDragOperation_

Then from my main script i have the following handler that was called from the boxDelegate script…


on storePaths_(incomingFileList)
     log "APP DELEGATE!"
     set my droppedPaths to incomingFileList
end storePaths_

it doesn’t seem to want to pass the values though. How can i get that information to my main script? Am I making this way more complicated than it needs to be?

Thanks,
Dave

How are you setting the value of theFiles?

Hi Shai,
that may have been my project that I posted up. I am not looking at that exact project example right now, I am doing this from memory and a similar project I have at hand.

In the BoxDelegate class, at the top there should be a

property appDelegate: missing value

In Interface Builder, you have to connect that to the app delegate class, or where ever you want to send a message to. So control-click on the BOX on the window layout, and drag from that connection dot to the app delegate (blue cube). This tells this instance of the box to talk to the active instance of the App Delegate.

In the ConcludeDrag… at the end there is a command such as

set appDelegate's myFiles to (owFords's fordDeep_(someNewFPaths))
--I am using Shane's "Fords" class to convert things

This sets the appDelegate’s property “myFiles” to either an AS List or NSArray (I forget which). So in your script, I dont think you need to call the method. In fact, I may have done this because you can not actually call a method to the instance, it only can call a class method. So you will never get your data passed to the instance, it just goes into the “class ether”. So, just set the variable, such as:
(in ConcludeDrag of boxDelegate:)

set appDelegate's droppedPaths to theFiles

Not sure if this will help. I found the old project and updated it to be more understandable and also pass the variable to AppDelegate:

http://www.paveglio.com/postimages/DragOnDropTest.zip

Sorry I left that part out. That’s being set by the drag and drop with this code in the BoxDelegate script…

set my theFiles to pb's readObjectsForClasses_options_({current application's |NSURL|}, theOptions)

Yes, SuperMacGuy, it was your project and it was very helpful. Thanks so much for taking the time to post it. I have to download Xcode again as I just got a new computer so I’ll be taking a look at the new example you made as well as the post you just made to see if I can make more sense of this.

Thanks again,
Dave

I finally have had time to get back to working on my project and trying to learn how to drag and drop. Thanks again for the helpful app example Chris, I’ve now been able to get this working as I want. :smiley:

Dave