我試圖在從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