我发现这很令人讨厌 - 直到有一天,我只是坐下来,拒绝起床,直到我有一个完美的工作。这..通过被称为...
-(void) mouseDown:(NSEvent *)click{
NSPoint mD = [NSScreen wtfIsTheMouse:click
relativeToView:self];
}
调用上NSScreen类别....
@implementation NSScreen (FlippingOut)
+ (NSPoint)wtfIsTheMouse:(NSEvent*)anyEevent
relativeToView:(NSView *)view {
NSScreen *now = [NSScreen currentScreenForMouseLocation];
return [now flipPoint:[now convertToScreenFromLocalPoint:event.locationInWindow relativeToView:view]];
}
- (NSPoint)flipPoint:(NSPoint)aPoint {
return (NSPoint) { aPoint.x,
self.frame.size.height - aPoint.y };
}
- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point
relativeToView:(NSView *)view {
NSPoint winP, scrnP, flipScrnP;
if(self) {
winP = [view convertPoint:point toView:nil];
scrnP = [[view window] convertBaseToScreen:winP];
flipScrnP = [self flipPoint:scrnP];
flipScrnP.y += [self frame].origin.y;
return flipScrnP;
} return NSZeroPoint;
}
@end
希望这样可以防止只是一个次要freakout ... 地方,总有一天 。对于孩子们来说,该死的。我为你的孩子求求你。
我的意思是,我已经覆盖了isFlipped方法。我的错,我没有说清楚。 – CD1212
重写'-isFlipped'方法对我也不适用。 –
在我的测试中,如果您使用convertPoint:** fromView:**,则'isFlipped {YES}'*将*将点转换为左上角原点。但*不*如果您使用convertPoint:** toView:** - 这是预期的,因为'toView:'假定该点已经在'self'视图的坐标系中。 –