• 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: Custom Shaped Buttons
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: NSToolbar not enabled
  • Next by Date: CILinearGradient on Leopard
  • Previous by thread: Re: Custom Shaped Buttons
  • Next by thread: memcpy strange behavior
  • Index(es):
    • Date
    • Thread