KDXCollectionView icon indicating copy to clipboard operation
KDXCollectionView copied to clipboard

Collection view's hitTest method eats clicks intended for subviews

Open tsfischer opened this issue 9 years ago • 0 comments

I am attempting to use KDXCollectionView as a grid of subviews which contain sub controls such as buttons. I was initially stumped as to why my buttons were not getting click events, but I tracked it down to the KDXCollectionView's override implementation of hitTest.

I believe what you really want to do is call the super's hitView, and only eat the clicks if they are not intended for a subview. The following code fixes it for me, although since I'm pulling this in as a Cocoapod it gets a little messy for me to change.

  • (NSView *)hitTest:(NSPoint)aPoint { NSView *hitView = [super hitTest:aPoint];

    if (!hitView && NSMouseInRect(aPoint, [self visibleRect], [self isFlipped])) { return self; }

    return hitView; }

tsfischer avatar Feb 11 '16 21:02 tsfischer