Le 19 nov. 2010 à 15:39, Graham Cox a écrit : > 1. Playing nice with the color panel requires a little care, because it's > shared by not only any color wells in your app, but by any responders that > implement -changeColor:
You're right, I'll try to be cautious. > 2. A table column only has one cell, reused as needed to draw each row. So > connecting the cell directly to the panel is a bad idea - all the colours in > all rows will change at once. I've learned that the hard way: the table column makes calls to copyWithZone: to get a transitory copy and all the stuff happens from that copy. Trying to interact directly with the cell is defeated: the self pointer is invalid. It is not even possible to set the cell as the target of the color panel action! > 3. Use MVC. If a property of your data model is a colour, then your > controller can set this from the color panel via -changeColor: on a first > responder (tableview, most likely) and some logic you'll need to implement to > establish which row is selected for colour input. Once the property is set, > you refresh the table as usual and the cell will display the colour for the > appropriate row. I was figuring out a way to short-circuit this round trip, but you finished to convince me that it is unwise. What method does the NSTableView use to inform the cell of its contents? -setObjectValue:? Thanks a lot for your precious advice. Vincent_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com