Search code examples
macoscocoanstableviewnstablecellview

NSTableView - select row and respond to mouse events immediately


I have a view based NSTableView in which the cells contain a number of controls including text fields and edit fields. When a user tries to click on a control within a cell in order to, for example, start editing a text field, the click's main objective is ignored and the cell gets selected. Another click is then needed to perform the action originally intended, and even this click is subject to a delay before it's taken into account.

How can I avoid this problem and have the row selected and the mouse event forwarded to the control in one go?


Solution

  • I solved this issue by subclassing NSTableView:

    @implementation QuickResponseTableView
    
    - (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event
    {
        // This allows the user to click on controls within a cell withough first having to select the cell row
        return YES;
    }
    
    @end