相关疑难解决方法(0)

在NSTextView上方更改NSView的NSCursor

我发现了类似的问题(这个),但我的问题似乎与视图层次结构有点联系.

我有一个NSTextView,然后作为兄弟视图,其他几个NSViews.

与上面链接的问题类似,我设置了一个跟踪区域,并将光标应用于:

class CursorChangingView: NSView {
    override func updateTrackingAreas() {
        let trackingArea = NSTrackingArea(rect: 
    }

    override func cursorUpdate(event: NSEvent) {
        NSCursor.arrowCursor().set()
    }
}
Run Code Online (Sandbox Code Playgroud)

它似乎在悬停时起作用,但会立即返回到IBeam Cursor,它是此CursorChangingView下NSTextViews的默认光标.

这是在鼠标悬停在某个NSView上时应用更改光标的正确方法吗?它下面的NSTextView是否覆盖了我的覆盖?

macos cocoa swift

5
推荐指数
1
解决办法
1256
查看次数

How to prevent a NSCursor from change?

I have a problem while I try to prevent a cursor from changing. I try to put an overlay view over entire window, but, if under that overlay exist an NSTextView, this will force cursor to change. I want to prevent that, and keep the arrow cursor until my overlay view will be removed.

Overriding the cursorUpdate method does not work:

override func cursorUpdate(with event: NSEvent) {
    return
}
Run Code Online (Sandbox Code Playgroud)

Thanks!

即使这个问题的答案也无济于事。此解决方案仅在叠加视图小于 TextView 时有效。

在此处输入图片说明

macos cocoa nsview nscursor swift

5
推荐指数
1
解决办法
543
查看次数

如何在Objective-C中更改鼠标光标

我正在制作一个图像编辑应用程序,但它看起来非常不完整,没有像在Photoshop中用于画笔的光标.如何设置图标,并在退出应用程序时将其更改回来?

这是我的头文件中的代码(以防万一需要):

@interface test : NSWindow <NSWindowDelegate> {
    IBOutlet id myView;

}

@end
Run Code Online (Sandbox Code Playgroud)

myView是一个NSView(customView),它将显示所有内容.

cocoa objective-c mouse-cursor

0
推荐指数
1
解决办法
5565
查看次数

标签 统计

cocoa ×3

macos ×2

swift ×2

mouse-cursor ×1

nscursor ×1

nsview ×1

objective-c ×1