hitTest在NSCell中为同一事件调用两次

时间:2013-11-29 12:46:57

标签: objective-c nstableview nsoutlineview hittest custom-cell

我正在为我的项目开发NSTextFieldCell的子类。

在某些情况下,此子类在其视图上绘制了NSButtonCell,其中包含:

-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{

       if(self.isPresent){

           [_button.cell drawWithFrame:cellFrame inView:controlView];
       }
 ....     
}

我正在实施hitTest

- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)controlView {

    NSLog(@"hitTest !");

    .............

     hitType |= NSCellHitTrackableArea;


     return hitType;

}

但我的问题是什么时候hitTest满足hitTestForEvent:被调用

对于相同的事件类型LeftMouseDown,每次

两次,这很奇怪。结果我

得到意想不到的结果。我只想要hitTestForEvent:只能被调用一次,用于

LeftMouseDown活动。感谢任何帮助。

0 个答案:

没有答案