View Full Version : Noob design question
Feb 21, 2008, 10:21 AM
I'm hoping to create my first real cocoa app. In it I want to have a scrollable pane that I can drag and drop "views" that are comprised of a textfield and a checkbox. The number of "views" in the scrollable pane would vary depending on the number of records the user has stored. I've been reading a lot about cocoa but I am struggling to decide how to start this application. Should I create a subclass of NSView with the textfield and checkbox in it programmatically? What scrollable view would be the best choice to drag my subclassed view in and out of?
Any help would be greatly appreciated
Feb 21, 2008, 10:45 AM
Sounds like you basically want a table with 2 columns, one of which has text in the other checkboxes. Therefore I'd use a NSTableView
Feb 21, 2008, 10:45 AM
Will the texfield and checkbox combinations be populated by drag and dropping or by the amount fo records stored (in a dictionary or database)?
I don't think you would need to subclass NSView for this because you can use Cocoa Bindings. All you would need to do is have a Model class for the data backbone (files object or whatever the records are), the View class (what you create in the Nib file in interface builder), and a controller class to connect everything together (binding).
Chapter 6 of the Hillegass book helped me out a lot with this concept as well as the following article: http://cocoadevcentral.com/articles/000080.php
Feb 21, 2008, 10:56 AM
Well the idea was that on the window there is a "view" with a checkbox and textbox on it that the user sets. When they are happy with it, they drag it into the scrollable area where it is displayed, and consequently added to the underlying data model. The "view" on the window would reset so the user could add another. By using a view for each "record" I thought I could allow the user to drag a record out of the scrollable area to delete it (kind of like dragging an icon off the dock). (tough to explain all this without knowing the jargon yet!)
Feb 21, 2008, 11:06 AM
Aha! That makes sense now. I'm pretty new to Cocoa as well but I get exactly what you are trying to do. Unfortunately, I haven't taken the dive into drag and drop just yet (altho I believe it is pretty easy and there is a apple dev document about it); however, it would be easy to do with 2 NSTableView's or 1 NSTableView and a text field + check box + button to input the data into the scrollable record area.
Feb 21, 2008, 07:14 PM
Thank you for your help. I'm out of the starting blocks.