hitTest不会在NSCell子类中调用
我正在为我的项目开发一个
NSCell
的子类。
在某些情况下,该子类在其视图中绘制了NSButtonCell
,其中:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
...
if (self.mode == PMVersatileCellButton) {
[_button drawWithFrame:cellFrame inView:controlView];
inView:controlView];
} else {
...
}
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
没问题。关于绘图,问题是响应点击按钮!
我正在尝试这样做:
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)controlView {
NSLog(@"hitTest !");
return [super hitTestForEvent:event inRect:frame ofView:controlView];
}
而且:
+ (BOOL)prefersTrackingUntilMouseUp {
return YES;
}
- (BOOL)startTrackingAt:(NSPoint) inView:(NSView *)
- (BOOL)trackMouse:(NSEvent *) inRect:(NSRect) ofView:(NSView *) untilMouseUp:(BOOL)
- (BOOL)continueTracking:(NSPoint) at:(NSPoint) inView:(NSView *)
- (void)stopTracking:(NSPoint) at:(NSPoint) inView:(NSView *) mouseIsUp:(BOOL)
但hitTest或任何其他人永远不会被称为...
只有+ (BOOL)prefersTrackingUntilMouseUp
被叫,这对我没有多大帮助......
任何的想法 ? ^^
没有找到相关结果
已邀请:
0 个回复