I am working on an app where I display unsupported (by XCode) file format). So I've subclassed NSBitmapImageRep
to display it in a subclass of NSImaageView
. I've set it up to be proportionally scallable (up or down). Now I need to add a possibility to get coordinates of pixel in a bitmap. So I've ovveride mouseDown: method:
- (void)mouseDown:(NSEvent *)theEvent
{
NSLog(@"mouseDown: %ld", [theEvent clickCount]);
NSPoint point = [theEvent locationInWindow];
NSLog(@"point x: %f and y: %f", point.x, point.y);
}
After getting NSPoint I should try to convert it to co-ordinates of a bitmap BUT first I have no idea How to solve the problem that locationInWindow returns NSPoint
of a NSImageView
, not of the bitmap which is ussually smaller and has unused margins in NSImageView
, but I can click on the margin and mouseDown event returns me NSPoint
in that margin. Do you have any idea what I shoud do?