• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Icon hit test
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Prev by Date: How can I prevent attributes to be pasted into my text view along with the text?
  • Next by Date: non-preference use info saving
  • Previous by thread: Apple default Help menu not visible in IB's MainMenu
  • Next by thread: non-preference use info saving
  • Index(es):
    • Date
    • Thread