[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Small NSTextView patch

From: Nicola Pero
Subject: Re: Small NSTextView patch
Date: Wed, 2 Jan 2002 07:48:19 +0000 (GMT)

> Hi,
> I've modified NSTextView: -mouseDown so that if our text storage contains 
> attributed strings with the NSLinkAttributeName and we 'click' on such 
> strings, NSTextView: -clickedOnLink: atIndex: is called so NSTextView's 
> delegate textView: clickedOnLink: atIndex: method will be called too.
> I included a patch with this mail.

Hi Ludovic, 

thanks - interesting patch - had a look into it and ... well the doc is
unclear but I felt like changing it - what about the following code for
managing links ?

 /* Manage the case that the click is on a link (a link is some chars
     with the NSLinkAttributeName set to something which is not-null).  */
    id link;

    /* What exactly is this link object, it's up to the programmer who
       is using the NSTextView and who originally created the link
       object and saved it under the NSLinkAttributeName in the text.
       If I were to use it, I would normally use a NSURL as the link
       object.  */
    link = [_textStorage attribute: NSLinkAttributeName
                         atIndex: startIndex
                         effectiveRange: NULL];
    if (link != null)
      if (_delegate != nil)
          SEL selector = @selector(textView:clickedOnLink:atIndex:);
          if ([_delegate respondsToSelector: selector])
              /* The _delegate returns YES if it handles the click, NO
                 if it doesn't -- and if it doesn't, we need to pass
                 handle the click elsewhere.  */
              if ([_delegate textView: self  clickedOnLink: link  
                             atIndex: charIndex])
                     [super mouseDown: theEvent];

The doc says that when the delegate returns NO to clickedOnLink:etc:etc:
the mouse down is passed to the next responder (the commented code in the
patch) - I'm not 100% convinced that this makes sense, I'd rather let
NSTextView -mouseDown: manage it in that case (which to me simply means -
if the click on the link is handled as a click on a link, ok; otherwise,
handle it as a normal click).

The other thing is (referring to the other email you sent me) - which
modifiers should be pressed to have the click `activated', in your opinion
?  I mean if just pressing the link activates it, then how would you edit
it ?  I suppose it's activated if you press on it with some modifier ?

Comments and suggestions welcome.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]