PDA

View Full Version : Question about Drag and Drop




mdeh
Oct 27, 2009, 09:01 PM
Hi all,
Could I ask the group this.


I am doing the "With and without" bindings tutorial of Apple, which includes Drag and drop. But, I noticed that many(?) cocoa controls already seem to implement this natively. So, for example, NSTextfield seems to allow a drop...without anything implemented. What am I missing? Hope this does not sound too silly. Or... In other words, what is there to gain by actually implementing the drag and drop methods in an application.

Thanks in advance.



kainjow
Oct 28, 2009, 08:35 AM
Text fields aren't as great of an example since you almost exclusively deal with text and they already support drag/drop of text, but if you wanted to accept dropping of an RTF file to insert the RTF contents, you'd have to handle that through a custom drag/drop.

Another example is allowing the user to drop a file onto your window/view to start some sort of processing on it. There is no way to do that out of the box. You'd have to override some NSView methods and handle the complete drag/drop operation yourself.

Or, say you have a list of files in a table view that represent some internal data. To allow the user to drag these items to the Finder to create new text files would require custom drag/drop handling.

Just a few examples :)

mdeh
Oct 28, 2009, 01:20 PM
Text fields aren't as great of an example since you almost exclusively deal with text and they already support drag/drop of text, but if you wanted to accept dropping of an RTF file to insert the RTF contents, you'd have to handle that through a custom drag/drop.

Another example is allowing the user to drop a file onto your window/view to start some sort of processing on it. There is no way to do that out of the box. You'd have to override some NSView methods and handle the complete drag/drop operation yourself.

Or, say you have a list of files in a table view that represent some internal data. To allow the user to drag these items to the Finder to create new text files would require custom drag/drop handling.

Just a few examples :)


Thanks Kainjow...always to the rescue!