objective-c - NSCursor 总是重置为 Arrow

标签 objective-c cocoa nscursor

为什么我不能让光标在鼠标拖动期间保持不动?一旦我开始拖动,它就会恢复为“箭头”(即使我在启动后在应用程序委托(delegate)中将其设置为张开的手)。

- (void)mouseDown:(NSEvent *)event
{
   [[NSCursor closedHandCursor] push];
}

- (void)mouseUp:(NSEvent *)event
{
   [NSCursor pop];
}

最佳答案

如果你不希望其他 View 在拖动时改变你的光标,你可以在 -mouseDown 中执行:

[[self window] disableCursorRects];

并在 -mouseUp 中:

[[self window] enableCursorRects];
[[self window] resetCursorRects];

关于objective-c - NSCursor 总是重置为 Arrow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11287523/

相关文章:

objective-c - 如何检测 Mac 应用程序中的应用程序是否处于非事件状态

iphone - 增加 UIButton 高亮时的触摸效果半径

cocoa - 如何让Lion的窗口调整NSCursor的大小?

iphone - CLLocation 方法 distanceFromLocation : Inaccurate results 出现问题

iphone - 在 UILabel 中显示表情符号?

c++ - 如何将 UTF8 std::string 转换为 NSString?

objective-c - 委托(delegate)、 socket 和鼠标事件的类设计

macos - 如何禁用我的应用程序中的所有 NSCursor 更新?

macos - 如何使用 NSCursor 显示自定义光标

ios - Realm 迁移 : Why in documentation it is recommended to call the migration block each time without checking the schema version before?