Hit detection on shapes within window
Hit detection on shapes within window
- Subject: Hit detection on shapes within window
- From: John Scalo <email@hidden>
- Date: Tue, 12 Nov 2002 16:33:18 -0800
I have a window with several closely placed images with odd shapes (i.e. not
rectangular or oval). I'd like to detect mouse clicks on these shapes and
momentarily change their image to a "pressed" state (using another image)
until the mouse is released.
My first inclination is to map the NSImages to NSBezierPaths and use
containsPoint: sending it the mouse down coordinates when the mouse is
clicked. However for the life of me I can't see how to get an NSBezierPath
from an NSImage. Is this possible? Perhaps in AppKit World all NSImages are
rectangular regardless of their content and alpha mask.
Another thought was to just implement these images as buttons with no border
and "momentary change" behavior (using the "pressed" image as the alt
image), but that really doesn't work because the rectangular representation
of the button is still used for hit detection rather than alpha mask part of
the image. Can NSButtonCell be subclassed to alter this behavior?
Any other approaches to consider here?
Thanks!
John
_______________________________________________
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.