Re: Programatically create URLs in NSTextView or ??
Re: Programatically create URLs in NSTextView or ??
- Subject: Re: Programatically create URLs in NSTextView or ??
- From: RameshPVK <email@hidden>
- Date: Tue, 6 Sep 2005 09:50:24 +0530
On 06-Sep-05, at 4:08 AM, email@hidden wrote:
Programatically create URLs in NSTextView or ??
You can do this by setting the attributes to the attributed string.
You can find the list of attributes in the NSAttributedString
Additions in Appkit. And now coming to set a text as URL you need to
do the following :
1) get the range of text
2) to that range set the following properties :
NSForegroundColorAttributeName and NSLinkAttributeName to set the
link object.
3) The hand cursor for the URL can be achieved by implementing the
following method
- (NSCursor *) cursorForLink: (NSObject *) linkObject
atIndex: (unsigned) charIndex
{
NSCursor *result = nil;
// If the delegate implements the method, consult it.
if ([[self delegate] respondsToSelector: @selector
(cursorForLink:atIndex:ofTextView:)])
result = [[self delegate] cursorForLink: linkObject
atIndex: charIndex ofTextView: self];
// If the delegate didn't implement it, or it did but
returned nil, substitute a guess.
if (result == nil)
{ result = [[self class] fingerCursor];
NSLog(@" gueesssssss......");
}
return result;
}
4) And to perform the action on clicking the URL , implement the
delegate
- (BOOL)textView:(NSTextView *)aTextView clickedOnLink:(id)link
Thanks,
Ramesh PVK
effigent India Pvt Ltd.
PH : (91) 09885187033
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden