discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug with NSTextAttachment ?


From: Nicolas Roard
Subject: Bug with NSTextAttachment ?
Date: Tue, 23 Jul 2002 19:23:19 +0100

Hello,

I want to use and attachment in a NSMutableAttributedString; it's working, but 
if I try to center
this attributed string in a NSTextView, it doesn't works well;

What I do is :
       NSTextAttachment* BR = [NSTextAttachment alloc];
       NSImage* img_br = [[NSImage alloc] initWithSize: NSMakeSize (200,0.1)];
       NSTextAttachmentCell* attachCell = [[NSTextAttachmentCell alloc] 
initImageCell: img_br];
       NSMutableParagraphStyle* paragraphStyle = [NSMutableParagraphStyle 
defaultParagraphStyle];
       NSMutableAttributedString* AS;

       [attachCell setBezeled: YES];
       [BR setAttachmentCell: attachCell];
         AS = [NSMutableAttributedString attributedStringWithAttachment: BR];
       [paragraphStyle setAlignment: NSCenterTextAlignment];
       [AS addAttribute: @"NSParagraphStyleAttributeName"
           value: paragraphStyle
           range: NSMakeRange(0,[AS length])];
       printf ("longueur de l'AS : %d , taille de l'AS : %d\n", [AS length], 
[AS size].width);

What the printf return is :

        longueur de l'AS : 1 , taille de l'AS : 0

In the text view, the attachment cell is visible, but not rightly centered; it 
starts from
the center of the textview, so it's too much on the right, like if the size of 
the attachment
wasn't considered. As [AS size].width return 0 I think it's perhaps a bug ?

By the way, I'm not sure my way of doing that is the right one so tell me if 
I'm wrong :)

--
Nicolas Roard <nicolas@witbe.net>
One Unix to rule them all, One Resolver to find them,
One IP to bring them all and in the zone bind them.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]