unable to catch mouseDown

  • Hello.
    I have a custom view to which I add a NSMatrix as subview.

    I've set the target and action of the cells and it's working like I want.

    Now I want to introduce some mode in which the behaviour is different.
    A mouseclick should no longer trigger the action.
    I want to catch the click in the view and process it further there since
    it's the appropriate place.

    I've tried setting the view to acceptFirstResponder and the Matrix to
    resignFirstResponder,
    yet it's not working.
    It behaves as if the Matrix lies on top of the view and not as if the click
    has to get through
    the custom view to the Matrix which is a subview.
    I don't understand that.

    Thanks!
  • Hi Jeffrey,
    > It behaves as if the Matrix lies on top of the view and not as if the
    click has to get through the custom view to the Matrix which is a subview.

    That is exactly how clicks work.  The first view to receive mouseDown: is
    the _deepest_ view that it the click hits. Please see the Cocoa event
    handling guide for more details, <
    http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/EventOverview/Int
    roduction/chapter_1_section_1.html

    > .

    You can modify the view that first receives -mouseDown: by overriding
    -[NSView hitTest:].  It's relatively rare though, and more useful when you
    do not know what your subviews will be.  Please consider if a plain
    NSMatrix is appropriate as a subview in the first place!

    -Ken

    On Sun, Feb 1, 2009 at 6:47 AM, Jeffrey Goines <
    <jeffrey.m.goines...> wrote:

    > Hello.
    > I have a custom view to which I add a NSMatrix as subview.
    >
    > I've set the target and action of the cells and it's working like I want.
    >
    > Now I want to introduce some mode in which the behaviour is different.
    > A mouseclick should no longer trigger the action.
    > I want to catch the click in the view and process it further there since
    > it's the appropriate place.
    >
    > I've tried setting the view to acceptFirstResponder and the Matrix to
    > resignFirstResponder,
    > yet it's not working.
    > It behaves as if the Matrix lies on top of the view and not as if the click
    > has to get through
    > the custom view to the Matrix which is a subview.
    > I don't understand that.
    >
    > Thanks!
    >