M a r k   C r o s b i e

You are in: Edit Panel with Table  Home  Resume  Linux  LEGO  Electronics  Movies  Mac OS X 

Edit Panel with Table
Overview Screenshots Download
Contact Mark at mark@mastincrosbie.com

Edit Panel with Table

2 January, 2003

This demo app builds upon the Simple Edit Panel application. It also uses a lot of Apple's excellent sample code from the MP3 player application that comes with the developer tools.

It is a demonstration of how a panel is launched from a main window and calls methods in the main window to change data. The data is displayed in a table, and the entry panel uses a form interface widget to accept three values to enter into the table. The entry form also supports cancelling the input which makes no change to the table.

Double-clicking on a row in the table will open the Edit panel which allows you to change a table row's values. Alternatively you can click on the edit button to open the panel if a row is highlighted.

The big change from the PanelTester is to use the Notification system in Cocoa to send messages back to the main window when adding or editing completes: the newly added or edited object is returned in the notification. If no change was made then a nil object is returned and the reciever makes no changes to the NSMutableArray backing the table. Much cleaner than the approach taken in the Simple Edit Panel.

The main window registers as a listener for the PFTTentryPanelClosing and PFTTeditPanelClosing notifications in the - init method. Id either notification arrives then the appropriate selector is called to execute the method to handle an edit or an entry to the table.

Notice how the drag-n-drop support code for a table is added but not fleshed out. See my next example for more on how to implement drag-n-drop.

Edit still needs to record which row in the table is being edited. Only one row can be edited at once, and the row index is recorded in the valueBeingEdited variable. Not very elegant.

The delete button removes the record at the specified row. It pops up a warning sheet if the user is currently editing or adding an entry. it checks the values for the editpc or epc window controllers, and if either of them are set it will warn the user that they cannot delete a row if they are currently adding or editing a row.

Cocoa Programming
An excellent resource on Cocoa programming that covers almost every aspect of development on Mac OS X.
Cocoa Recipes for Mac OS X
A step-by-step guide through developing a multi-document application in Cocoa.
Cocoa Programming for Mac OS X
My first Cocoa book - clearly written guides and excellent coverage of the basics.

© 2002-2004 Mark Crosbie   shareright © 2002 Phlash