• 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
Solved: Link & Table Cursors in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Solved: Link & Table Cursors in NSTextView


  • Subject: Solved: Link & Table Cursors in NSTextView
  • From: Glen Simmons <email@hidden>
  • Date: Mon, 27 Feb 2006 19:40:41 -0600

On Feb 27, 2006, at 3:26 PM, Douglas Davidson wrote:

On Feb 24, 2006, at 2:48 PM, Glen Simmons wrote:

I'm using code from the TextLinks sample (http:// developer.apple.com/samplecode/TextLinks/TextLinks.html) to get a pointing hand cursor over links in my NSTextView subclass. But this has broken the resize cursors that appear over the edges of tables. I've tried calling [super resetCursorRects] at the beginning and at the end of my subclass' -resetCursorRects method and either will restore the table cursor behavior, but breaks the link cursors. Any ideas? Do I now have to write code to handle cursors for tables myself?


None of this should be necessary--links get the pointing hand cursor by default, based on the text view's linkTextAttributes. If you need custom cursors, you can use NSCursorAttributeName. If you really need to override the default cursor handling in some way that this doesn't support, don't use cursor rects; instead, override mouseMoved:, call the super method, and then afterward set the cursor if the mouse is over some region you are particularly interested in, otherwise leave it alone.

Maybe it shouldn't be necessary, but I don't get a pointing hand cursor by default. Maybe I'm doing something wrong. I just tried making a new Cocoa Doc based project and added an NSTextView to the doc nib window. Built and ran, then typed "http://www.apple.com"; in the text view, right-clicked on it and chose "Make Link" - no pointing hand. I assume that this should work based on your statement. Is there something else I need to do?


I then subclassed NSTextView and overrode linkTextAttributes to return the dictionary from super, with the addition of the pointing hand cursor set as the object for the key NSCursorAttributeName (thanks for that tip) and now I get a pointing hand. Since this works and doesn't impact table cursors, this is what I'm going with.

Thanks!
Glen Simmons
_______________________________________________
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: Solved: Link & Table Cursors in NSTextView
      • From: Jim Correia <email@hidden>
References: 
 >Link & Table Cursors in NSTextView (From: Glen Simmons <email@hidden>)
 >Re: Link & Table Cursors in NSTextView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Help needed
  • Next by Date: when to register
  • Previous by thread: Re: Link & Table Cursors in NSTextView
  • Next by thread: Re: Solved: Link & Table Cursors in NSTextView
  • Index(es):
    • Date
    • Thread