Heyo, quick question. I've got an NSControl and NSCell, and am doing some logic with testing if the mouse is down, and making sure the event location is within the bounds of the cell's control view.
I've tried quite a bit of different ways of getting the event point converted to the control view. Would you mid telling me if there's something painfully obvious with this code? Here's a snippet of code extracted from the cell: - (void) drawBezelWithFrame:(NSRect) frame inView:(NSView *) controlView { NSEvent * currentEvent = [NSApp currentEvent]; BOOL isMouseUp = true; BOOL isLeftMouseDown = ([currentEvent type] == NSLeftMouseDown); if(isLeftMouseDown) { isMouseUp = false; NSPoint localPoint; BOOL coordsAreScreen = ([currentEvent window]==nil); NSPoint windowPoint = [currentEvent locationInWindow]; if(coordsAreScreen) { NSLog(@"coords are screen"); windowPoint = [[[self controlView] window] convertScreenToBase:windowPoint]; } if(windowPoint.x < 0 || windowPoint.y < 0) { isLeftMouseDown = false; isMouseUp = true; } else { //this block is where I can't get "localPoint" to correctly convert. NSLog(@"windowPoint: %@",GDPrintGetPrintedNSPoint(windowPoint)); localPoint = [[self controlView] convertPoint:windowPoint toView:nil]; NSLog(@"localPoint: %@",GDPrintGetPrintedNSPoint(localPoint)); localPoint = [[[[self controlView] window] contentView] convertPoint:windowPoint fromView:[self controlView]]; NSLog(@"localPoint2: %@",GDPrintGetPrintedNSPoint(localPoint)); localPoint = [[self controlView] convertPoint:windowPoint fromView:[self controlView]]; NSLog(@"localPoint3: %@",GDPrintGetPrintedNSPoint(localPoint)); NSLog(@"is in rect: %i",NSPointInRect(localPoint,frame)); NSLog(@"frame: %@",GDPrintGetPrintedNSRect(frame)); if(!NSPointInRect(localPoint,frame)) isLeftMouseDown = false; } } } I also threw this up on pastebin if you want some color: http://pastebin.com/ZyTju8UY To me the first "localPoint = ..." should be the correct way to convert the windowPoint to the control views' coordinate space. But it's never right. Any ideas? Thanks! _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com