• 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
Re: How to disable/gray an NSTextfield (used as static text)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to disable/gray an NSTextfield (used as static text)


  • Subject: Re: How to disable/gray an NSTextfield (used as static text)
  • From: "Sean McBride" <email@hidden>
  • Date: Mon, 22 Nov 2004 00:43:46 -0500

This is very delayed reply :), but anyway...

Daniel Todd Currie (email@hidden) on Sat, Oct 23, 2004 10:27 PM said:

>>I am using an NSTextField as a text label (ie not editable nor
>>selectable).  I'd like to 'disable' this textfield so that it appears
>>gray instead of black.
>
>If you really wanted to, I suppose you could subclass NSTextField and
>make it so that text labels gray when they receive the -setEnabled:
>message...  Otherwise, this is just as good a way as any other:
>
>[myTextLabel setTextColor:[NSColor disabledControlTextColor]];

A good idea, but incredibly apparently not so simple. :(  I subclassed
like so:

- (void)setEnabled:(BOOL)flag
{
	[super setEnabled:flag];

	if (flag == NO) {
		[self setTextColor:[NSColor disabledControlTextColor]];
	} else {
		[self setTextColor:[NSColor controlTextColor]];
	}
}

But when I setEnabled:0, the colour changes, but not to the correct colour!

I've put a very simple sample app here:
<http://www.cam.org/~cwatson/GreyingTextTest.sitx> (16 KB)

This seems too simple for me to be messing up, but I'd be happy to be
proven wrong. :)

Thanks!

--
"I object to violence because when it appears to do good, the good is
only temporary; the evil it does is permanent." - Gandhi



 _______________________________________________
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: How to disable/gray an NSTextfield (used as static text)
      • From: Dietmar Planitzer <email@hidden>
  • Prev by Date: Crash on [event locationInWindow]
  • Next by Date: NSDocument beginSheet on a new document
  • Previous by thread: Re: Crash on [event locationInWindow]
  • Next by thread: Re: How to disable/gray an NSTextfield (used as static text)
  • Index(es):
    • Date
    • Thread