• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programatically create URLs in NSTextView or ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Programatically create URLs in NSTextView or ??
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Message Forwarding for + Methods
  • Next by Date: Re: Message Forwarding for + Methods
  • Previous by thread: Programatically create URLs in NSTextView or ??
  • Next by thread: Re: Programatically create URLs in NSTextView or ??
  • Index(es):
    • Date
    • Thread