Re: Custom Shaped Buttons
Re: Custom Shaped Buttons
- Subject: Re: Custom Shaped Buttons
- From: Erik Buck <email@hidden>
- Date: Thu, 20 Mar 2008 08:40:36 -0700 (PDT)
If all you want is a custom shape button, subclass NSButton and override a few methods, -hitTest:. http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/occ/instm/NSView/hitTest:
Use whatever image you want. Then implement hitTest
Composed in mail:
- (BOOL)isOpaque
{
return NO;
}
- (BOOL)hitTest:(NSPoint)aPoint
{
BOOL result = [super hitTest:aPoint];
if(result)
{
NSPoint localPoint = [self convertPoint:aPoint fromView:[self superview]];
if(local point doesn't hit non-transparent color in my image)
{
result = NO;
}
}
return result;
}
_______________________________________________
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