• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie question on tableview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question on tableview


  • Subject: Re: Newbie question on tableview
  • From: Daniel Todd Currie <email@hidden>
  • Date: Wed, 20 Oct 2004 15:15:19 +0900

One of the problems with your suggestion, is that double-clicking is the standard way of editing a cell in an NSTableView. If you make it so that double-clicking in the table opens a new window, then you will also have to develop a new means of editing the cells.

A different and simple way to achieve your desired functionality would be as follows:

1. Set your table columns to not be editable in Interface Builder.
2. In the popup info window, add fields for the user to enter Car Make and Car Model.
3. Subclass NSTableView and set your table instance to be an instance of this custom class in Interface Builder.
4. Create a method in your NSTableView subclass that will open the info window, and will enter the values into the table when the window is closed.
5. In your controller class's -awakeFromNib method, send a -setDoubleAction: message to your table instance that will set the new method from step 4 as the double-click action.

The other question I would ask, is why not have all of the data editable in the table? If you have columns for make, model, color, year, etc., then you won't need to worry about double-clicks and info windows at all. If the color and year columns are things that the user may or may not want to use, it would be quite easy to add or remove these columns according to the user's preferences.

Now... A more advanced developer may decide that he wants to have a couple of columns viewable (such as make/model), while having more detailed information attached to each table datum, that would be editable in an info window that opens on double-click. In this case, you would need to override the way your table interprets mouse clicks, since there is no way to directly tell the table not to edit cells on double-click. I don't think this is the right approach.

Yet another--and preferable--way of obtaining this advanced functionality, is to have something along the lines of an inspector window (or a drawer might be fun also; I like drawers). When a table row is selected, this inspector becomes populated with the make, model, year, color, etc. When the user edits these values in the inspector, they are changed in the table. This system does not require double-clicks to do anything but edit table values; the inspector window can be opened any number of ways; by a menu item, by simple selection of a table item, or by a button next to the table.

I hope you haven't found this to be too condescending, and have rather found it to be evidence that there are many ways to accomplish the similar things, that there is a great deal of nuance to working with APIs as vast as the Cocoa API, that you must always have the user in mind when you are developing, and that the easiest way to do things is often the best. The APIs have been developed with good app design in mind, so if you find you are fighting the API, you should reconsider your project's direction.

-- DTC


On 2004 Oct 20, at 14:07, Steve Gran wrote:

First let me say I am a very newbie Newbie
:)
Self learning Cocoa programming (actually self learning programming by programming in Cocoa) and I have a question. So please excuse me if I don't make clear.

I have a small app (as I try to learn I make apps just do a few things to help me understand how to get things done). Anyway in this learning program I have a table view that the user can add, edit, and delete items in the table.

What I'd like to do is to be able to have the user double click on a row which would bring up a new window (that window will contain additional data items the user will enter).

So for example, in the table in the main window I have "Car Make" and "Car Model" in which the user will can enter "BMW M3" or "Ford Mustang", etc. Then the user should be able to click on the row that has "Ford Mustang" which brings up a new window which I will add additional items (like "Color", "Year", etc.) which the user will add.

So...

How do I get the double click action to occur on the specific row the user selects?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Newbie question on tableview (From: Steve Gran <email@hidden>)

  • Prev by Date: Re: Project Builder broken
  • Next by Date: Re: Highlighting Drag Target
  • Previous by thread: Newbie question on tableview
  • Next by thread: file type check method
  • Index(es):
    • Date
    • Thread