Intercepting Mouse down events to NSTextField Controls


#1

I have a table view that is bound to an NSArraryController. I want users to be able to edit single and multiple selections of the tableview from a detail view that consists of NSTextfields and NSComboBoxes. There are occasions where users forget that they have selected multiple items in the tableview (and hence the bound NSArrayController) and proceed to edit rows of data, unaware that they are actually mutating more than one row of data. When a user tabs into a control like an NSTextField or NSComboBox, I want to alert the user with a message box before they actually tab into the control that they are changing more than one row of data. I can easily deduce that multiple items in my NSArrayController are selected, throw an NSRunAlert, and give users an option to make a choice to continue editing, but at that point, I have already entered focus into the control and any attempt to leave that control will still change the selected item(s). I tried overriding acceptsFirstResponder, and conducting my selection count test in that selector, but acceptsFirstResponder gets called more than once, and then the control passes focus onto the next control in the kew view loop. What I want to accomplish is to discard the editing and resign focus from the control. I tried to override mouseDown: in my NSComboBox, but that doesn’t actually work. I can mouseDown: in my custom NSComboBox class, and not invoke the superclass’ mouseDown:, but for some reason the field editor still becomes active. I even thought about not presenting the field editor until the user indicates that they actually want to edit multiple rows, but - windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject will use a default field editor if you return nil.

Any thoughts to my conundrum? Other best practice ideas?

Patrick