作者:hf40kiu | 来源:互联网 | 2022-12-26 14:27
文章来源:http:www.cocoachina.combbsread.php?tid52088-(void)mouseMoved:(NSEvent*)theEvent{
文章来源:http://www.cocoachina.com/bbs/read.php?tid=52088
- (void)mouseMoved:(NSEvent *)theEvent
{
//- (NSPoint)locationInWindow 返回鼠标在当前窗口的坐标
//- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView 返回aPoint在aView坐标系中,调用者的相对坐标
NSPoint windowPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
if ([self mouse:windowPoint inRect:rect]) //windowPoint是否在rect中
{
NSLog(@"YES!");
[self setSelectable:NO]; //关闭NSTextView的鼠标选择属性
[[NSCursor openHandCursor] set]; //将鼠标指针控制器设置为openHandCursor手势
}
else
{
NSLog(@"NO!");
[self setSelectable:YES]; //打开NSTextView的鼠标选择属性
[self setEditable:YES]; //当NSTextView的鼠标选择属性关闭时,编辑属性也会一同被关闭,所以此处需要手动打开
}
}