How to: Address Book-like text UI

  • Good morning!

    I want to create a view with similar behavior to the Address Book
    card view: text blocks are positioned in the view under program
    control, but can be selected as a continuous text (unless in edit
    mode). Of course I want to use the Cocoa text system.

    My understanding so far is as follows:

    To enable the continuous selection, all text has to be in a single
    NSTextStorage object.

    My first idea to control the placement of text blocks was to use one
    NSTextContainer per block (as suggested in the documentation e.g. for
    multi column layouts). Unfortunately I did not find a means so far to
    control the amount of text which is layed out in a text container.
    That is, NSLayoutManager seems to always fill a text container, while
    I need to assign a pre-determined piece of text to each container. Is
    there a way to tell NSLayoutManager to move to the next text
    container at a defined point in the text (as would be needed for
    forced page breaks or column breaks in more traditional layout)?

    Another way would be to use a subclass of NSTextBlock. This should
    work well, but since NSTextBlock is available beginning with Tiger
    only, Address Book must be using another approach (at least in the
    past).

    Any advice would be appreciated - I would like to avoid too many detours. ;-)

    Thanks
    Kai
  • On 05.09.2007, at 09:38, Kai Brüning wrote:
    > I want to create a view with similar behavior to the Address Book
    > card view: text blocks are positioned in the view under program
    > control, but can be selected as a continuous text (unless in edit
    > mode). Of course I want to use the Cocoa text system.
    >
    > My understanding so far is as follows:
    >
    > To enable the continuous selection, all text has to be in a single
    > NSTextStorage object.

      I don't think address book actually does continuous selection. At
    least it doesn't work reliably. So my guess would be that they're
    probably using NSTextAttachments for the edit fields (or whatever the
    class was named that does in-line images etc.), and have a separate
    text view for the fields that aren't focused that is only selectable.

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • On Sep 5, 2007, at 12:38 AM, Kai Brüning wrote:

    > My first idea to control the placement of text blocks was to use
    > one NSTextContainer per block (as suggested in the documentation
    > e.g. for multi column layouts). Unfortunately I did not find a
    > means so far to control the amount of text which is layed out in a
    > text container. That is, NSLayoutManager seems to always fill a
    > text container, while I need to assign a pre-determined piece of
    > text to each container. Is there a way to tell NSLayoutManager to
    > move to the next text container at a defined point in the text (as
    > would be needed for forced page breaks or column breaks in more
    > traditional layout)?

    Yes, a form feed character (NSFormFeedCharacter = 0xc) is treated as
    a container break.

    Douglas Davidson
  • On 05.09.2007, at 09:38, Kai Brüning wrote:

    > I want to create a view with similar behavior to the Address Book
    > card view: text blocks are positioned in the view under program
    > control, but can be selected as a continuous text (unless in edit
    > mode). Of course I want to use the Cocoa text system.

    WWDC 2003 had a "Advanced xxx" session #4xx that demoed (with sample
    code) how to customize NSTextField to create an Address Book like
    view,,,

    HTH,
    Tom_E
  • > On 05.09.2007, at 09:38, Kai Brüning wrote:
    >
    >> I want to create a view with similar behavior to the Address Book card view: text blocks are positioned in the view under program control, but can be selected as a continuous text (unless in edit mode). Of course I want to use the Cocoa text system.
    >
    > WWDC 2003 had a "Advanced xxx" session #4xx that demoed (with sample code) how to customize NSTextField to create an Address Book like view,,,

    Hi Thomas,

    this sounds very promising - only, how can I access this session and/or the sampe code? The ADC content in the iTunes Store goes back to 2004 only.

    Thanks in advance,
    Kai
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today