Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSStepper in NSTableCellView has no effect

I’m using a regular (not subclassed) NSTableCellView in a view-based table view. It has the initial image and text field views. I added an NSStepper to the view.

The text field is bound to tableCellView.objectValue.quantity. The stepper’s value is bound to tableCellView.objectValue.quantity too.

The problem is that when running the app, when I click the stepper it doesn’t seem to get the mouse event, neither arrow gets highlighted, the value is not incremented or decremented.

If I set the double action of the table view it gets triggered if I double-click the stepper as if it was transparent.

What am I missing?

Thanks!

like image 998
wdyp Avatar asked Oct 28 '12 10:10

wdyp


1 Answers

You should look at the documentation but easiest is that you need to subclass NSTableView and override this method to validate the proposed first responder. As the document states NSTableViews disallow some controls to be used unless the row is first selected. Even then it still may discard some.

- (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event {
    return YES;
}
like image 200
Robert Payne Avatar answered Sep 24 '22 03:09

Robert Payne