How to change appeareance of the view based tableviews during editing process?

111 views Asked by At

I’m developing my first app for Mac OS X. It allows to edit the tableviews’ contents and I want to recreate behavior of how the cells are edited in the Things App. It should work like this: double click on the cell should start advanced editing of the cell’s contents. Problem is that I don’t understand how to implement this for the view based tableviews.

enter image description here

I already have read Table View Programming Guide for Mac and watched session 120 from UWDC’11 about customizing the view based tableviews, but that didn’t help me too much.

I assume that I should somehow track an editing event and change cell’s prototype from the standard one to the more advanced right after editing started. I know how to change the appearance of the cell using both subclassing and cell’s prototypes. But I don’t understand how to change the cell’s view during editing process.

Anyway, is it right thing to create this kind of the custom controls using standard NSTableView?

Please notice that I’m using Core Data, NSArrayController and Cocoa Bindings in this app.

1

There are 1 answers

1
Wil Shipley On

Initiating editing via double-click is actually surprisingly hard with view-based NSTableView—it’s set up to do the Finder-like “click-and-wait” for editing, and if you try to implement your own “double-click initiates editing” it’ll often get confused and try to do its own as well, and you’ll end up turning editing off/on at bizarro times. Believe me, I tried.

That aside, in view-based mode it’s pretty easy to add/remove widgets or move them around when you’re editing—you need to track the basic “am I editing this cell”, of course, but once you do that you can simple create widgets and place them in your NSTableCellView where you like. You’ll probably not want to replace the actual text field—modify it, sure, but let Apple’s code do the basic job of turning it from non-editable to editable and the like.