HitTest is not called in an NSCell subclass

I am 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. about the drawing, the problem is to click on the button!

I am 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 will never be called ...

Only + (BOOL)prefersTrackingUntilMouseUp , which doesn't help me much ...

Any idea? ^^

+4
source share

Source: https://habr.com/ru/post/1337710/


All Articles