• 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
Truncating strings to fit a text field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Truncating strings to fit a text field


  • Subject: Truncating strings to fit a text field
  • From: Mark Alldritt <email@hidden>
  • Date: Thu, 25 Mar 2004 19:50:10 -0800

Hi All,

Sorry to bug you all with a simple Cocoa question, but search as I might, I
cannot find a simple answer to this.

I want to display a file path in a NSTextField instance. I want to truncate
a long file path with a ... (like I can do in Carbon with
TruncString/TruncText). What's the magic incantation to make this happen in
Cocoa?

There is NSString's sizeWithAttributes, but I don't see anything that will
"do the right thing" given an available width.

Cheers
-Mark

---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB: http://www.latenightsw.com/ CANADA V8V-4M9
AIM: markalldritt
_______________________________________________
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.


  • Follow-Ups:
    • Re: Truncating strings to fit a text field
      • From: Satoshi Matsumoto <email@hidden>
  • Prev by Date: Re: Making an NSConnection from a BSD socket
  • Next by Date: Re: Scale and convert image to JPEG using NSImage, NSImageRep, etc?
  • Previous by thread: Example code using WSMethodInvocationAddSerializationOverride? (WebServicesCore woes)
  • Next by thread: Re: Truncating strings to fit a text field
  • Index(es):
    • Date
    • Thread