Skip navigation.
 
mlRe: drawing custom button in cocoa
FROM : Mike Ferris
DATE : Thu Jan 02 17:32:50 2003

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_removed>>
> Date: Thu Jan 2, 2003  2:22:49 AM US/Pacific
> To: <<email_removed>>
> 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_removed>
> 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_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mldrawing custom button in cocoa orochi_huang Jan 2, 11:22
mlRe: drawing custom button in cocoa Mike Ferris Jan 2, 17:32
mlRe: drawing custom button in cocoa Janek Priimann Jan 2, 17:34