【发布时间】:2019-09-22 01:39:21
【问题描述】:
iOS 13 终于引入了对鼠标的支持。我一直在徒劳地寻找有关如何处理鼠标事件的文档。在 macOS 10+ 中有 NSEvent 类 https://developer.apple.com/documentation/appkit/nsevent 作为 AppKit 的一部分。 iOS 13 中对应的类是什么?有人可以指点我一些文档/示例吗?我已经尝试过https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html 中的代码,但它在 iOS 13 中不起作用。我使用的是 Xcode 11。我对获取鼠标事件信息(例如,pressedMouseButtons、mouseLocation、buttonNumber)特别感兴趣。
- (void)mouseDown:(NSEvent *)theEvent {
[self setFrameColor:[NSColor redColor]];
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)theEvent {
[self setFrameColor:[NSColor greenColor]];
[self setNeedsDisplay:YES];
}
【问题讨论】:
标签: objective-c mouseevent appkit ios13 xcode11