• 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
NSTextField/View and shadows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField/View and shadows


  • Subject: NSTextField/View and shadows
  • From: Ricky Sharp <email@hidden>
  • Date: Sun, 14 Nov 2004 15:34:54 -0600

All UI elements in my kiosk employ the use of shadowed text. My custom NSButton already does this by using an attributed string that has a shadow. I then render that string into a cached NSImage.

I was hoping that I could use NSTextField or NSTextView to render shadowed text without the need of subclassing. But I could only get a non-editable NSTextField to have a shadow, and had to do so programatically. Attempting to set the shadow view the Font Panel in IB did nothing.

When made editable, the shadow is lost at runtime. Thinking that this had something to do with the field editor, I wrote a simple subclass of both NSTextField and NSTextView. I then provided an implementation for windowWillReturnFieldEditor in my controller (to return an instance of my custom NSTextView).

While things in general work, I get numerous drawing artifacts. Specifically, the shadow I use has a blur of 4 and offset of 2,-2. Thus, there's at least 3 pixels below the descender value. While the shadow often draws below the descender, inserting or removing characters will leave remnants of the shadow. I think this is a limitation of AppKit as I can reproduce the artifacts in TextEdit.

I've tried looking to see if there was some method of increasing the line height to take into account the extra pixels for the shadow, but can't find anything.

I thought of overriding drawRect so I would have complete control over the rendering, but I lose things like highlight and insertion point drawing. I guess I'd have to figure out how to do that myself.

Does anyone know of any examples of custom NSTextField/View that performs their own drawing? Searching in Google just gave me custom subclasses that needed something special for text handling and not the actual rendering of the text.

TIA,

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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


  • Prev by Date: Re: Access instance var from NSValueTransformer
  • Next by Date: Re: Execute On-Load
  • Previous by thread: Re: Access instance var from NSValueTransformer
  • Next by thread: Best way to catch signals in a Cocoa app
  • Index(es):
    • Date
    • Thread