如何将“鼠标悬停”侦听器添加到IKImageBrowserCell (不是NSView或NSCell),而只是从NSObject继承?
发布于 2013-03-23 00:54:08
因为IKImageBrowserCell是NSObject的子类,所以我建议您在IKImageBrowserView子类中使用鼠标事件方法。您可以使用相应事件的locationInWindow检测鼠标下的单元格,如下所示
- (void)mouseEntered:(NSEvent *)theEvent {
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
NSInteger itemIndex = [self indexOfItemAtPoint:point];
//Use this itemIndex to do manipulations on your item or cell.
}它将在NSResponder类中。IKmageBrowserView是NSView的子类,后者是NSResponder的子类。
IKImageBrowserView : NSView : NSResponder : NSObject
https://stackoverflow.com/questions/15570259
复制相似问题