Re: NSTextView paste:
Re: NSTextView paste:
- Subject: Re: NSTextView paste:
- From: Seth Willits <email@hidden>
- Date: Mon, 13 Aug 2012 14:45:53 -0700
On Aug 13, 2012, at 10:54 AM, ecir hana wrote:
> I have a NSTextView, where the user can paste plain text into.
>
> When the users has "foo" in the pasteboard I would like "bar" to be pasted.
> In other words, a user goes to, say, a web browser, selects "foo", cmd+c,
> switches to my NSTextView, cmd+v and "bar" appears at insertion point.
>
> Please, does anyone know how to approach this?
>
> I thought about subclassing "readSelectionFromPasteboard:type:" but what to
> do then? Or is there better way of doing this?
Typed in Mail…
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard type:(NSString *)type
{
if ([type isEqual:NSStringPboardType]) {
if ([[pboard stringForType:type] isEqual:@"foo"]) {
[self insertText:@"bar"];
return YES;
}
}
return [super readSelectionFromPasteboard:pboard type:type];
}
--
Seth Willits
_______________________________________________
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