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];
}
And :
+ (BOOL)prefersTrackingUntilMouseUp {
return YES;
}
- (BOOL)startTrackingAt:(NSPoint) inView:(NSView *)
- (BOOL)trackMouse:(NSEvent *) inRect:(NSRect ) ofView:(NSView *) 直到MouseUp:(BOOL)
- (BOOL)continueTracking:(NSPoint) at:(NSPoint) inView:(NSView *)
- (void) stopTracking:(NSPoint) at:(NSPoint) inView:(NSView *) mouseIsUp:(BOOL)
但 hitTest 或任何其他永远不会被调用...
只有 + (BOOL)prefersTrackingUntilMouseUp
得到打电话,这对我没有多大帮助...
知道吗? ^^
I'm working on a subclass of NSCell
for my project.
This subclass has, in some situation a NSButtonCell
drawn on its view, with this :
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
...
if (self.mode == PMVersatileCellButton) {
[_button drawWithFrame:cellFrame inView:controlView];
inView:controlView];
} else {
...
}
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
No prob. about the drawing, the problem is respond to click on the button !
I'm trying to do this with :
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)controlView {
NSLog(@"hitTest !");
return [super hitTestForEvent:event inRect:frame ofView:controlView];
}
And :
+ (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)
But hitTest or any others never get called...
Only + (BOOL)prefersTrackingUntilMouseUp
get called, which doesn't help me so much...
Any idea ? ^^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论