That solved it. Thanks, Ken
- j On Mon, Mar 10, 2008 at 8:38 PM, Ken Ferry <[EMAIL PROTECTED]> 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 PROTECTED]> 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 PROTECTED] > > work: http://www.secondgearllc.com/ > > play: http://www.carpeaqua.com > > _______________________________________________ > > > > 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/kenferry%40gmail.com > > > > This email sent to [EMAIL PROTECTED] > > > -- - Justin Williams [EMAIL PROTECTED] work: http://www.secondgearllc.com/ play: http://www.carpeaqua.com _______________________________________________ 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]
