Re: Clicking NSButton causes parent view to draw in transparent background
Re: Clicking NSButton causes parent view to draw in transparent background
- Subject: Re: Clicking NSButton causes parent view to draw in transparent background
- From: "Justin Williams" <email@hidden>
- Date: Mon, 10 Mar 2008 21:03:18 -0500
That solved it.
Thanks, Ken
- j
On Mon, Mar 10, 2008 at 8:38 PM, Ken Ferry <email@hidden> wrote:
> > // 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
> >
>
--
-
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