我正在尝试更改NSTextField
从 NIB 加载的窗口工作表中的鼠标光标。
NSTextField
根据文档,我对resetCursorRects
.
- (void) resetCursorRects {
[self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]];
}
这永远不会被调用。即使在添加以下内容后也不行NSWindowViewController
:
- (void) windowDidLoad {
[self.window invalidateCursorRectsForView:self.linkTextField];
}
我还尝试通过在子类中添加以下内容来使用跟踪区域NSTextField
:
- (void) awakeFromNib {
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
options:(NSTrackingCursorUpdate | NSTrackingActiveAlways)
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
}
- (void)cursorUpdate:(NSEvent *)theEvent {
[[NSCursor pointingHandCursor] set];
}
也没有用。我究竟做错了什么?