Looks fine to me.  Is there any chance the correct text *is* being drawn but is 
subsequently erased or drawn over by something else in the rest of the 
drawRect: method?

--Andy

 
On Thursday, January 07, 2010, at 03:29PM, "Michael Craig" <[email protected]> 
wrote:
>Hi all,
>This has me completely boggled.
>
>I've got a GameController with some BOOL instance variables that it uses to
>make certain gamestate information available to other objects. I've also got
>a GameView that looks at those BOOLs and conditionally appends an
>NSMutableString before it gets drawn. The relevant chunk of drawRect: looks
>like this:
>
>    NSRect infoRect = NSMakeRect(hBuff,
>                                                     vBuff,
>                                                     cardSize.width,
>                                                     [self
>frame].size.height - vBuff * 4);
>    NSDictionary *infoAtts = [NSDictionary
>               dictionaryWithObjectsAndKeys: [NSFont labelFontOfSize:
>infoFontSize],
>
> NSFontAttributeName,
>                                                              rightAligned,
>
> NSParagraphStyleAttributeName, nil];
>    NSNumber *cardsInDeck = [NSNumber numberWithUnsignedInteger:
>[theDeck.cardPile count]];
>    NSMutableString *infoStr = [NSMutableString stringWithString: @"Cards in
>deck: "];
>    [infoStr appendString: [cardsInDeck stringValue]];
>    if ([theDeck.cardPile count] == 0) {
>        [infoStr appendString: @"\n\nThe deck is empty."];              //
>*2*
>    }
>    if (gameCon.invalidStack) {
>        [infoStr appendString: @"\n\nThat's an invalid stack."];        //
>*1*
>    }
>    [infoStr drawInRect: infoRect
>            withAttributes: infoAtts];
>
>The number of cards in the deck is always displayed, and additional text
>should be drawn if the deck is empty or if gameCon.invalidStack is YES. The
>empty deck text is drawn as intended, but the invalidStack text is never
>drawn. However, it IS being appended to infoStr at all the right times
>(tested by printf'ing the contents of infoStr after the above chunk).
>
>If I move the line marked *1* to come after the line marked *2*, then both
>messages are drawn when the deck is empty, as one would expect.
>
>If I move the line marked *1* one line down (so it's outside of the
>invalidStack if statement and the if is empty), then invalidStack message is
>drawn at all times, as one would expect.
>
>So what is keeping it from drawing the appended text when it happens inside
>the invalidStack if statement? Like I said above, the if statement itself
>works fine.
>
>Thanks,
>Mike
>_______________________________________________
>
>Cocoa-dev mailing list ([email protected])
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com
>
>This email sent to [email protected]
>
>
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to