• 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: Drawing A Mutable String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing A Mutable String


  • Subject: Re: Drawing A Mutable String
  • From: Andy Lee <email@hidden>
  • Date: Thu, 07 Jan 2010 16:02:36 -0500

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@hidden> 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@hidden)
>
>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:
>
>This email sent to email@hidden
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Drawing A Mutable String (From: Michael Craig <email@hidden>)

  • Prev by Date: Re: A password strength checker
  • Next by Date: Re: Drawing A Mutable String
  • Previous by thread: Drawing A Mutable String
  • Next by thread: Re: Drawing A Mutable String
  • Index(es):
    • Date
    • Thread