我试图在从NIB加载的窗口表中更改NSTextField
的鼠标光标。无法更改NSTextField的鼠标光标
继文档后,我已将子类别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];
}
也不能工作。我究竟做错了什么?
你解决这个问题?我有类似的问题。 – Jensen
@Jensen Nope。你在尝试不同的东西吗? – hpique
只是通过在其超级视图中覆盖mouseMoved方法来解决此问题。 – Jensen