tags:

views:

37

answers:

0

I'm trying to register specific user activity in a view. I have an NSView that has a NSTextField, a NSDatePicker and a NSButton (checkbox). I want to know when the user enters into the text field or the picker or when he/she clicks the checkbox.

I'm currently using hitTest but it fires a bunch of times even when I just move the mouse over the view, not even click!

What I liked about hitTest is it gave me one place to register the activity no matter what control the user clicked on versus subclassing the above controls and trying to figure out how to capture each activity.

How can I make hitTest fire only once? Here's the code:

- (NSView *)hitTest:(NSPoint)aPoint {
    NSView *v = [super hitTest:aPoint];

    if(NSPointInRect(aPoint,[self convertRect:[self bounds] toView:[self superview]])) {
         NSLog(@"hitTest fired"); // this should only happen once 
    }

return v;

}

Thanks!