I have an NSTableView in a dialogue box which is bound to a collection of CoreData model instances via an NSArrayController in 'Entity Name' mode. The table displays the name
s of the array of managed objects in a single column. This works well.
The names in the table rows are editable. If the user edits a name when there is no sorting applied to the table then editing proceeds normally. After pressing Return, the new name is recorded and input focus stays in the NSTableView. However, if the column heading in the table view is clicked upon in order to sort the table of names, input focus goes astray after editing. It stays within the window, or wider view (not sure which), but it goes out of the table; the focus ring vanishes and the background colour of the highlighted item changes from blue to grey. Pressing Tab pops input focus back into the table view again.
This only happens if the table contents are sorted. If "Continuously Updates Value" is chosen for the binding, it's catastrophic as the minute any characters are entered, the table view seems to want to re-sort itself (that's OK) and focus jumps out of it (that's not OK as the user was in the middle of trying to type something).
As far as this aspect of the system is concerned, there's no code - it's all done with bindings established in Interface Builder. Presumably, I've inadvertently set or cleared some option that I shouldn't have.
In case it helps the reader figure out what's up - I also have a modal sheet attached to the dialogue box containing the NSTableView. The sheet is used to edit the details of an item selected in the table view. The controls in this are also connected with bindings to the CoreData model using the same NSArrayController as the dialogue box 'behind' the sheet. The same problem is seen - as soon as a new name is typed in, focus is pulled back to the dialogue box 'behind' the modal sheet.
The only code involved is that used to handle the 'edit this item' action and start the modal session for the sheet.
What's going on? Where is the focus going and why is being moved just because of re-sorting in the NSTableView?
Thanks!