hmm... okay. I get what you're saying about range, and I did wonder about that, but it seems strange to be required to always set it by range, for each line. Shouldn't there just be a single, persistent setting -- a default, as it were? I'll look at the typingAttributes, but this text is being set programmatically, not by the user. Don't know if that makes a difference... ("Typing" certainly sounds like user input to me.) As I say, I would have expected the IB Attributes panel to be able to set it, but it's not working, for whatever reason.
J. On 2010-06-06, at 5:29 PM, Ross Carter wrote: > On Jun 6, 2010, at 1:21 PM, James Maxwell wrote: > >> I have a NSTextView that's displaying MIDI info from my app's current MIDI >> input device. I show this info in a couple of places - one is in a "MIDI >> Setup" type window, and the other is in an Inspector window. I want the >> Inspector window to show this data in light grey text against a dark >> background (whereas the MIDI Setup window shows it in black on white). >> I'm doing this from my MIDI controller class, which is instantiated as a nib >> in IB. The controller has an IBOutlet to the desired text view. In the >> controller's init I tried just setting the foreground colour of my text >> view's textStorage, but that didn't work -- it still displays as black text. >> It does work to do this: >> >> [[mainWindowMIDIMonitor textStorage] setForegroundColor:[NSColor >> lightGrayColor]]; >> [mainWindowMIDIMonitor performSelectorOnMainThread:@selector(setString:) >> withObject:monitorInfo waitUntilDone:NO]; >> >> But it doesn't display the first input in light grey. It starts out as >> black, than changes after the first entry... go figure... >> Is there no way to just permanently set the text colour to light grey once? >> Do I have to have the controller hold a reference to the text view, rather >> than just using an outlet? > > This might help; forgive me if it doesn't address your situation. In an > NSTextStorage object, text attributes are values that apply to some range of > text in the object. If the object has no text, then setting attributes is > meaningless. If a textStorage length is 0, and you set a foreground color > attribute, and subsequently add some text, the text does not necessarily show > up with that foreground color. > > When plain text without attributes is added to a textStorage object--as, for > example, with input from the keyboard--the NSTextView uses its > typingAttributes dictionary to apply attributes to the new text. So, if > you've got a new NSTextView whose NSTextStorage length is 0, and you are > going to add some plain text to it, you must first set the typingAttributes > of the NSTextView to the desired attributes. > > -setForegroundColor: is one of the scriptability methods of NSTextStorage. > Those methods are not recommended for use in non-scripting situations. > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com > > This email sent to jbmaxw...@rubato-music.com James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com