Re: Fake Buttons
Re: Fake Buttons
- Subject: Re: Fake Buttons
- From: publiclook <email@hidden>
- Date: Mon, 2 Jun 2003 11:23:43 -0400
See NSView's -hitTest method and the NSRectFillUsingOperation()
function.
- (NSView *)hitTest:(NSPoint)aPoint
Returns the farthest descendant of the receiver in the view hierarchy
(including itself) that contains aPoint, or nil if aPoint lies
completely outside the receiver. aPoint is in the coordinate system of
the receivers superview, not of the receiver itself.
This method is used primarily by an NSWindow to determine which NSView
should receive a mouse-down event. Youd rarely need invoke this
method, but you might want to override it to have a view object hide
mouse-down events from its subviews.
See Also: mouse:inRect:, convertPoint:toView:
NSRectFillUsingOperation
Fills a rectangle using an NSCompositingOperation.
void NSRectFillUsingOperation(NSRect aRect, NSCompositingOperation op)
Discussion
Fills aRect with the current color, using the compositing operation op.
On Sunday, June 1, 2003, at 11:25 PM, 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. 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.
_______________________________________________
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.