• 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: Clicking NSButton causes parent view to draw in transparent background
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clicking NSButton causes parent view to draw in transparent background


  • Subject: Re: Clicking NSButton causes parent view to draw in transparent background
  • From: "Ken Ferry" <email@hidden>
  • Date: Mon, 10 Mar 2008 18:38:53 -0700

>  // Want to draw it in the center of the view.
>     NSPoint startPoint;
>     startPoint.x = rect.origin.x + rect.size.width / 2 - size.width / 2;
>     startPoint.y = rect.origin.y + rect.size.height / 2 - size.height / 2;

rect is the dirty region in your view, which may not be the whole thing.

You want to center the drawing in [self bounds], not in rect.

-Ken

On Mon, Mar 10, 2008 at 6:28 PM, Justin Williams <email@hidden> wrote:
> I have a borderless image-based NSButton placed on top of a custom
>  view that prints out a value on an nstextfieldcell.   When the button
>  is clicked, the textfieldcell is drawing in the background of my
>  button.
>
>  You can see what it looks like at the following url:
>  http://carpeaqua.com/images/nsbuttondrawerror.png
>
>  In my custom NSView, I'm drawing the textfieldcell centered using the
>  following code:
>
>
>  - (void)drawRect:(NSRect)rect {
>  // Here is the code that sets up a gradient & the NSAttributedString
>
>         [selectedDateField setAttributedStringValue:selectedDate];
>
>     NSSize size = [selectedDate size];
>
>  // Want to draw it in the center of the view.
>     NSPoint startPoint;
>     startPoint.x = rect.origin.x + rect.size.width / 2 - size.width / 2;
>     startPoint.y = rect.origin.y + rect.size.height / 2 - size.height / 2;
>     NSRect currentDateRect = NSMakeRect(startPoint.x, startPoint.y,
>  size.width + 10, size.height);
>
>  // Draw it in the view
>     [[selectedDateField cell] drawWithFrame:currentDateRect inView:self];
>  }
>
>
>  Any help would be appreciated.
>
>  --
>  -
>  Justin Williams
>  email@hidden
>  work: http://www.secondgearllc.com/
>  play: http://www.carpeaqua.com
>  _______________________________________________
>
>  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

  • Follow-Ups:
    • Re: Clicking NSButton causes parent view to draw in transparent background
      • From: "Justin Williams" <email@hidden>
References: 
 >Clicking NSButton causes parent view to draw in transparent background (From: "Justin Williams" <email@hidden>)

  • Prev by Date: Re: NSURLDownload and userInfo
  • Next by Date: Re: NSURLDownload and userInfo
  • Previous by thread: Clicking NSButton causes parent view to draw in transparent background
  • Next by thread: Re: Clicking NSButton causes parent view to draw in transparent background
  • Index(es):
    • Date
    • Thread