NSTextView 中的 MouseMoved 通知会生成消息“共享项目数组为空”

2024-03-16

我正在使用自定义mouseMove事件在NSTextView当光标位于内容插图之外时,将光标设置为指针。当它位于可编辑区域内时,我正在调用[super mouseMove]:

- (void)mouseMoved:(NSEvent*)event {
    NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
    
    if ((point.x > self.textContainerInset.width &&
         point.x < self.frame.size.width - self.textContainerInset.width)
    ) {
        [super mouseMoved:event];
    } else if (point.x > 10) {
        [NSCursor.arrowCursor set];
    }
}

当选择一个越线在我的文本中(意味着行尾的空白部分)并将鼠标悬停在所选内容上,[super mouseMoved:event]鼠标移动的每个像素都会生成以下消息:

Appname[29357:853497] [Framework] Shared items array is empty
Appname[29357:853497] [Framework] No shared items can be accessed

我很困惑为什么会发生这种情况,原因可能是什么?

EDIT:即使没有子类化,这似乎也会发生NSTextView。这可能是 macOS Catalina 中的一个错误。对我来说,它似乎不会造成任何其他问题。


我找到了解决方案。它与子类化的标准建议相冲突。但据我所知,它不会引入任何不需要的行为。子类化您的 NSTextView 并重写此方法(是的,无需调用超类,这是使解决方案起作用的部分,叹息):

override func mouseMoved(with event: NSEvent) {} // swift

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

NSTextView 中的 MouseMoved 通知会生成消息“共享项目数组为空” 的相关文章

随机推荐