Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Collection view's hitTest method eats clicks intended for subviews #3

Open
tsfischer opened this issue Feb 11, 2016 · 0 comments
Open

Comments

@tsfischer
Copy link

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;
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant