How can I change the cursor when it's over an NSButton?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
[yourButton addCursorRect:[yourButton bounds] cursor:[theCursorYouWant]];
回答2:
You should subclass NSButton first, then add the code below.
- (void)resetCursorRects
{
if (self.cursor) {
[self addCursorRect:[self bounds] cursor: self.cursor];
} else {
[super resetCursorRects];
}
}
Now you can set cursor as you like.
[self.button setCursor:[NSCursor pointingHandCursor]];
Note: add cursor
as a property of your subclass, like this:
@property (strong) NSCursor *cursor;
回答3:
Have the button add a cursor rect.