Attachment Cell with Image

  • I have an NSTextView, where I add an NSTextAttachment which has an
    NSTextAttachmentCell which has an NSImage.

    I save this NSTextView and read it again.

    The attachments are still there, but they all show the default file-
    icon - not my NSImage.
    I could, after readRTFDFromFile:, go through all attachments and do
    setAttachmentCell: where appropriate.

    But - is there a better way? Maybe some delegate method being called
    when an NSTextAttachment is being read?

    Some other idea?

    Gerriet.
  • On Oct 12, 2006, at 10:20 AM, Gerriet M. Denkmann wrote:

    > I have an NSTextView, where I add an NSTextAttachment which has an
    > NSTextAttachmentCell which has an NSImage.
    >
    > I save this NSTextView and read it again.
    >
    > The attachments are still there, but they all show the default file-
    > icon - not my NSImage.

    NSTextAttachment fundamentally is designed to represent an attached
    file.  The persistent portion, the model part if you will, of an
    NSTextAttachment is the file--that is, the NSTextAttachment's file
    wrapper.  The text attachment cell is merely a visual representation
    of that file, the attachment's view portion.  If you do not supply a
    text attachment cell, NSTextAttachment will by default generate a
    suitable text attachment cell from the file wrapper, based on its
    understanding of file types, but it will not generate a file wrapper
    from a cell in the reverse situation.

    If you want your attachments to be persistent, choose a suitable file
    type and supply a file wrapper with file contents and an appropriate
    name.  You may then also supply a custom attachment cell, if you
    wish, to customize the visual representation of the attachment within
    your application, but remember that other applications will use the
    standard representation based on the attached file.

    Douglas Davidson
previous month october 2006 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 31          
Go to today