• 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
Text Color in custom NSFormatter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Text Color in custom NSFormatter


  • Subject: Text Color in custom NSFormatter
  • From: email@hidden
  • Date: Tue, 23 Jul 2002 17:39:47 +0200

Hello,

Here's a newbie question. I wrote a custom formatter for a column in a NSTableView. It is a subclass of NSFormatter. It's supposed to take numbers as the object and convert it to a time string for the format HH:MM:SS. So far it works fine. If the value is negative, the string should be displayed in gray instead of black. I tried overriding attributedStringForObjectValue() like shown below, but it doesn't have any effect. What am I doing wrong?


public NSAttributedString attributedStringForObjectValue(Object object, NSDictionary attributes) throws NSFormatter.FormattingException
{
// Check if we have a negative time. If so make the text color gray...

NSMutableDictionary style = new NSMutableDictionary(attributes);

if (GetSeconds(object) < 0)
{

style.setObjectForKey(NSColor.grayColor(),"NSForegroundColorAttributeName"
);
}

// Convert the date to a string...

String string = stringForObjectValue(object);
return new NSAttributedString(string,(NSDictionary)style);
}


Another question concerning the formatter. How do I use drag & drop in IB to attach a custom formatter to a table column. I couldn't figure it out, so I did it via source code (as can be expected from a Carbon/PowerPlant programmer), but I guess that's not the preferred way of doing things in Cocoa

Thanks,
Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Proper retain/release etiquette
  • Next by Date: Re: Document App: IB connections 101
  • Previous by thread: Re: Creating an automatic build number with PBX?
  • Next by thread: Nibtool and appleglot
  • Index(es):
    • Date
    • Thread