Re: [Q] How to let the pasteboard know a file type?
Re: [Q] How to let the pasteboard know a file type?
- Subject: Re: [Q] How to let the pasteboard know a file type?
- From: JongAm Park <email@hidden>
- Date: Fri, 19 Dec 2008 09:45:43 -0800
Hello. I found out that NSCreateFilenamePboardType() would help. So, I
tried it like :
My code example is :
In awakeFromNib
NSString <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html> *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@"mov");
[myNSTableView registerForDraggedTypes:[NSArray <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html> arryWithObject:quickTimeFileNamesPboardType]];
In -tableView:writeRowsWithIndexes:toPasteboard:
NSString <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html> *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@"mov");
anIndex = [selectedRowsIndexSet firstIndex];
while( anIndex != NSNotFound )
{
fileName = [NSString <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html> stringWithFormat:@"%@/%@.mov", configPath, [[dataArray objectAtIndex:anIndex] name]];
[fileNamesArray addObject:fileName];
// Next index
anIndex = [selectedRowIndexSet indexGreaterThanIndex:anIndex];
}
[pboard declareTypes:[NSArray <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html> arrayWithObjects:quicktimeFilenamesPboardType, nil] owner:nil];
isSuccessful = [pboard setPropertyList:fileNamesArray forType:quicktimeFilenamesPboardType];
...
When I check what information is exported from my program with the Drag
Peeker X, it shows :
Item Reference: 19884c10
Item Bounds (tlbr): { 86, 1, 104, 191 }
Number of flavors: 0
Strangely, it doesn't have any flavor of data.
Is there anything wrong how I use the NSCreateNSFilenamePboardType? How
to use it properly?
Thank you in advance.
P.S. By the way, is it normal to put 'furl' and 'hfs' flavor when
NSFilenamesPboardType is used? Because an array of file names are added
to the pasteboard, I thought that only file name strings were added. But
it turned out no-so-true.
JongAm Park wrote:
Hi,
Thanks to a utility program, called DragPeeker X, I found out some
clue why the FCP treated dragged file as a file with unknown type.
When I dragged the same file from the Finder to the FCP, it shows :
Number of Items: 1
1. Item Reference: 19884c10
Item Bounds (tlbr): { 86, 1, 104, 191 }
Number of flavors: 2
1. Flavor Type: 'furl'
Flavor Flags: 0
Length: 54
Data:
66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74
file://localhost
2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E
/Volumes/172.16.
32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33
246.146/MOV/0003
59 42 2E 6D 6F 76
YB.mov 2. Flavor Type: 'hfs '
Flavor Flags: 300
Length: 80
Data:
4D 6F 6F 56 3F 3F 3F 3F 00 00 FF 98 00 00 00 13
MooV????........
0A 30 30 30 33 59 42 2E 6D 6F 76 DC 00 00 00 00
.0003YB.mov.....
FF FF FF FF 00 00 00 00 00 25 F0 A0 A0 31 60 34
.........%...1`4
91 F6 C0 A0 BF FF DA 80 84 04 20 42 91 F6 6B 44
.......... B..kD
91 F6 C0 A0 00 86 B4 00 17 BB 17 FC BF FF DA C4
................
But if I drag one from my application to the FCP, it shows :
Number of Items: 1
1. Item Reference: c0c0a
Item Bounds (tlbr): { 219, 244, 219, 244 }
Number of flavors: 2
1. Flavor Type: 'furl'
Flavor Flags: 0
Length: 54
Data:
66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74
file://localhost
2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E
/Volumes/172.16.
32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33
246.146/MOV/0003
59 42 2E 6D 6F 76
YB.mov 2. Flavor Type: 'hfs '
Flavor Flags: 0
Length: 80
Data:
00 00 00 00 00 00 00 00 00 00 FF 98 00 00 00 13
................
0A 30 30 30 33 59 42 2E 6D 6F 76 FC 00 25 DB A0
.0003YB.mov..%..
00 00 00 06 00 18 80 00 00 00 00 60 00 25 8E B0
...........`.%..
90 10 7A 44 BF FF DA 70 44 04 20 42 90 10 7D EC
..zD...pD. B..}.
00 00 00 02 BF FF DA 90 00 00 00 20 BF FF DC F4
........... ....
( I also tried NSURLPboardType and NSFileContentsPboardType. But they
didn't make information like above appear. )
The PboardType I used was NSFilenamesPboardType.
The major difference between those are in the 2nd flavor type 'hfs'.
Their flavor flags are different: one is 300, while the other is 0.
What actually matters, I think, is the data of the 2nd flavor.
The one using the Finder starts with MooV????, which says that the
dragged item is a QuickTime movie, while the one from my application
doesn't contain anything. ( all 0's. )
So, is there any way to mark that the interested file is in a specific
type, i.e. QuickTime movie file?
Thank you.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden