On Sun, Jun 6, 2010 at 10:21 AM, James Maxwell
<jbmaxw...@rubato-music.com> 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];

Probably not related to your immediate problem, but I wanted to point
out that this code is unsafe. I assume you're using
performSelectorOnMainThread: because this code is running on a
background thread. If that's the case, then your first line is
dangerous, because NSTextView is not thread safe. You should run both
lines of code (and anything else manipulating any aspect of the view)
on the main thread.

Mike
_______________________________________________

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

Reply via email to