Re: Fake Buttons
Re: Fake Buttons
- Subject: Re: Fake Buttons
- From: Stéphane Sudre <email@hidden>
- Date: Mon, 2 Jun 2003 09:01:27 +0200
On lundi, juin 2, 2003, at 05:25 AM, email@hidden wrote:
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.
Are you using NSRectFill? alpha is not working with this function. I
learnt it not so long ago.
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?
Since you need to intercept the code used to find the "responder" of
the click, you can't just draw views with some alpha.
_______________________________________________
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.