• 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: Custom Object in Attributed String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Object in Attributed String


  • Subject: Re: Custom Object in Attributed String
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 16 Feb 2006 17:59:18 -0800


On Feb 15, 2006, at 10:55 AM, Lorenzo wrote:

I would like to insert my custom hyper-text within an attributedString.
It is a formatted number looking like 00.00 or 000.0
The user cannot modify the text of this object but he can select it and
change the font/size/style/color of the interger part or the decimal part.
He could vary the formatter of the number like we developers use to do with
Interface Builder.


Where should I learn to add and manage hyper-text to my attributedString?


The behavioral changes can most likely be done at the text view delegate level; take a look at the delegate methods starting with shouldChange, which you can use to e.g. forbid any changes that change the text (as opposed to the attributes) of a range intersecting a given range. You can also control user changes to selected ranges, if you want to do that.


How do you keep track of where your custom text is in the document? For that, I would suggest using a custom attribute. Just pick a name and values for your attribute, and add it to your string in the appropriate ranges; then your delegate methods can look for this attribute. You may want to use different values for different instances (what happens if two instances of this special text abut each other?)

You will want to consider what happens to your special text under copy/paste. Obviously when you paste into another app that doesn't recognize this behavior, the text will no longer be special, but what do you want to happen within your app? If you want to preserve custom attributes, you'll need to add a custom pasteboard type; custom attributes are preserved, for example, under archiving, but not under the RTF representation that is used by default for rich text on the pasteboard.

Douglas Davidson

_______________________________________________
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: Custom Object in Attributed String
      • From: Lorenzo <email@hidden>
References: 
 >Custom Object in Attributed String (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: why would anyone want to do that?
  • Next by Date: Re: Displaying Text Vertically
  • Previous by thread: Custom Object in Attributed String
  • Next by thread: Re: Custom Object in Attributed String
  • Index(es):
    • Date
    • Thread