• 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: drawing custom button in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing custom button in cocoa


  • Subject: Re: drawing custom button in cocoa
  • From: Mike Ferris <email@hidden>
  • Date: Thu, 2 Jan 2003 08:32:50 -0800

If you want to limit the active area of your button the best way is probably to override -hitTest:.

You should figure out if the point is in your active area (inside the button shape) and return self if it is and return [super hitTest:event] if it is not.

To do the test, you can do whatever is easiest. One way would be to create an NSBezierPath for the outline of the active area and use it to hit test.

Mike


Begin forwarded message:

From: "orochi_huang" <email@hidden>
Date: Thu Jan 2, 2003 2:22:49 AM US/Pacific
To: <email@hidden>
Subject: drawing custom button in cocoa

I want to draw a custom shape button in my cocoa program,so I created a custom view in Interface Builder and subclassed NSButton to recevie mouse click action,I overwrited the drawRect: function to make myself shape.the shape shows correct,but when I click region outside the shape but in the rect of button,button click actions as if the mouse is in the shape region,I noticed it is because I filled the rect only,but not the region.But I didn't found anything in Cocoa can create a region from paths and rects,so how I can create custom button in cocoa?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >drawing custom button in cocoa (From: "orochi_huang" <email@hidden>)

  • Prev by Date: objects.nib files and MacCVSPro
  • Next by Date: loading windows & SIGBUS
  • Previous by thread: drawing custom button in cocoa
  • Next by thread: Re: straight-C DNS lookup with timeout?
  • Index(es):
    • Date
    • Thread