resetCursorRects不工作(新光标只在鼠标进入时闪烁) [英] resetCursorRects not working (new cursor only flashes as mouse enters)

查看:628
本文介绍了resetCursorRects不工作(新光标只在鼠标进入时闪烁)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个自定义视图,需要一个特殊的光标(而不是通常的箭头)。
我使用resetCursorRects来设置新的光标及其区域,但是当鼠标进入rect区域时,新的光标只会短暂出现,返回到箭头。

I'm creating a custom view that needs a special cursor (instead of the usual arrow). I'm using the resetCursorRects to setup the new cursor and its area, but the new cursor only appears briefly when the mouse enters the rect area, returning to arrow.

为了更好地检查事情,我创建了一个新项目,创建一个新的自定义视图(基于NSView),将其添加到窗口,但问题仍然存在。
自定义视图代码:

To check things better, I've created a new project, create a new custom view (based on NSView), add it to the window, but the problem remains. The custom view code:

#import "TestView.h"

@implementation TestView

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];

    [[NSColor redColor]set];
    [NSBezierPath fillRect:self.bounds];
}

-(void)resetCursorRects
{
    [self addCursorRect:NSMakeRect(2, 2, 40, 40) cursor:[NSCursor openHandCursor]];
}

@end

[super resetCursorRects]或[self discardCursorRects]在addCursorRect之前,但不会发生。我做错了什么?

I've tried things like [super resetCursorRects] or [self discardCursorRects] before the addCursorRect, but nothings happens. Am I doing anything wrong?

推荐答案

解决了重新启动...经过多个小时的工作,我发现它是一些

Solved with a reboot... After many hours of work, I discovered it was some sort of bug from the system, which was solved by a simple reboot.

谢谢大家的时间...

Thank you all for your time...

这篇关于resetCursorRects不工作(新光标只在鼠标进入时闪烁)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆