NSTextView custom type pasteboard support howto?
NSTextView custom type pasteboard support howto?
- Subject: NSTextView custom type pasteboard support howto?
- From: "Mark's Studio" <email@hidden>
- Date: Fri, 4 Oct 2002 19:28:30 +0200
I try to implement a new type to a textview
I have overridden
- (NSArray*)acceptableDragTypes, - (NSArray *)readablePasteboardTypes
to add myCustomType and
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard
type:(NSString *)type{
if ([type isEqualToString: myCustomType]){
//insert type, a custom NSTextAttachment......
}
return YES;
}
else return [super readSelectionFromPasteboard:pboard type:type];
}
to read it from the pasteboard
i also had to override
- (NSString *)preferredPasteboardTypeFromArray:(NSArray
*)availableTypes restrictedToTypesFromArray:(NSArray *)allowedTypes{
NSString *typeString;
NSEnumerator *enumerator = [availableTypes objectEnumerator];
while ((typeString = [enumerator nextObject]) != nil){
if ([typeString isEqualToString: myCustomType]){
return myCustomType;
}
}
return [super preferredPasteboardTypeFromArray:availableTypes
restrictedToTypesFromArray:allowedTypes];
}
to get my preferred type.
and that's all working with drag coming from another place.
But the problem is how to drag, copy and paste myCustomType within the
textview.
If i make a selection containing myCustomType and some default types,
and i don't override any of the write... metode,
and drag that selection to another place within the textview,
myCustomType is missing
if i override these write... metode
and drag the selection to another place within the textview, all the
default types are missing,
what am i doing wrong?
- (NSArray *)writablePasteboardTypes{
NSMutableArray *dragTypes = [NSMutableArray arrayWithArray:[super
writablePasteboardTypes]];
if([self containsMyCustomTypeAttachment]){
[dragTypes addObject: myCustomType];
}
return dragTypes;
}
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard
type:(NSString *)type
{
if([type isEqualToString: myCustomType]){
//put myCustomType from the selection onto the pasteboard...
}else
return [super writeSelectionToPasteboard:pboard type:type];
}
Thanks
Peter Mark
Mark's Recording Studio A/S
Faelledvej 19 b DK2200 N
Copenhagen Denmark
Tel: +45 35366078 Fax: +45 35366038
www.marks-studio.dk
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.