Icon hit test
Icon hit test
- Subject: Icon hit test
- From: Tae-Won Ha <email@hidden>
- Date: Sun, 30 Mar 2003 23:57:21 +0200
I'm experimenting with Icon Service of Carbon. I've got a problem...
T_T:
First my code:
- (void)drawRect:(NSRect)rect {
CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y,
rect.size.width, rect.size.height);
CGContextRef context = (CGContextRef)[[NSGraphicsContext
currentContext] graphicsPort];
PlotIconRefInContext (
context,
&cgRect,
kAlignNone,
kTransformNone,
NULL,
kPlotIconRefNormalFlags,
iconRef // iconRef instance variable, got it in initWithFrame
method
);
}
- (void)mouseDown:(NSEvent *)theEvent {
NSPoint point = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
Point pnt = {(short)point.x, 128 - (short)point.y}; // 128 - point.y,
cuz view not flipped
Rect rect = {0,0,128,128}; // 128 X 128, cuz view is 128 X 128
Boolean inIcon = PtInIconRef(
&pnt,
&rect,
kAlignNone,
kIconServicesNormalUsageFlag,
iconRef
);
if(inIcon) {
NSLog(@"Mouse down in Icon: (%d|%d)", pnt.v, pnt.h);
}
}
I subclassed NSView and implemented those two + initWithFrame methods.
Icon is displayed well, however the hit test does not work. what's
wrong?
--
Tae. =)
_______________________________________________
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.