Fake Buttons
Fake Buttons
- Subject: Fake Buttons
- From: email@hidden
- Date: Sun, 1 Jun 2003 23:25:30 -0400
I want to draw objects in a view such that they respond to events
through the normal event mechanisms. I figure the best way to do this
is to make these objects subclasses of NSView, but the trick is in
getting mouse clicks to be only effective in drawn regions. In other
words I am trying to create irregularly shaped buttons (though I don't
want to create an NSButton). At first it seems immediately obvious that
the solution is to create somehow an NSView with a transparent
background onto which the responding image is drawn. Then, to get the
image to respond, the NSView just asks the NSBezierPath (the image) if
it contains the mouse click location. This would work, accept multiple
views may overlap in which case the top view would respond to the mouse
click even if it were in a region that shows a bottom view's image.
Moreover, tests that I have conducted show that filling an NSView with
a transparent color only fills it with black. Anyway, I think this
explains the predicament. I could simply draw the objects and handle
the events and state changes and so on from the same NSView, but that's
messy and out of tune with the event mechanism. So, to cut it short,
how can I create irregularly objects that respond to clicks without
special care from the superview?
_______________________________________________
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.