开发者

Convert NSPoint in screen coordinates to window coordinates

开发者 https://www.devze.com 2023-01-21 15:22 出处:网络
I am implementing drag and drop in a cocoa application and I am using the following method from the NSDraggingSource Protocol:

I am implementing drag and drop in a cocoa application and I am using the following method from the NSDraggingSource Protocol:

- (void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint{

The NSPoint is given in screen coordinates and I need it in window or view coordinates. If the method was called with an NSEvent I could do the following:

    -(void)mouseDown:(NSEvent *)pTheEvent {

 NSPoint tvarMouseInWindow = [pTheEvent locationInWindow];
 NSPoint tvarMouseInView   = [self convertPoint:tvarMouseInWindow fromView:nil]; }

But I cannot figur开发者_C百科e out how to do it with just an NSPoint. Thanks in advance!


Have a look at the NSWindow documentation, there is a

- (NSPoint)convertScreenToBase:(NSPoint)aPoint

which will let you convert the point to window coordinates.

0

精彩评论

暂无评论...
验证码 换一张
取 消