Substitute a check box or a popup for as a field editor in a tableview

  • I am porting a MacApp program to cocoa. I have hit a road block.  I
    have created a Tableview of text fields that I work fine. I need a
    Tableview as the items and their type are not always the same and are
    specified by data. Hence I can not just define the fields in IB. Their
    value can always be shown as text, but this is not always the best way
    to edit them.  Some of the items in the Tableview are Booleans and
    some are a selection from a standard lists. The behavior I had in
    MacApp was, when the user clicks on one of these fields an appropriate
    field editor appears in the field. If it is a normal text field the
    regular text fieldeditior is fine.  With either the Booleans or the
    Lists, a check box or a pop-up to edit the field is shown as the field
    editor. When the user hits Enter, the appropriate Boolean value or
    associated PopUp-text value is shown in the tableview field.

    I have been reading about use of windowWillReturnFieldEditor but this
    seems to want a NSTextView as the editor.  I want to provide some form
    of button. Any help on an approach would be appreciated. Thanks
  • Use the NSTableView delegate method
    -tableView:dataCellForTableColumn:row:, have it return an NSCell
    subclass of the appropriate type, and either bind it or set its target
    and action manually.

    You seem to be confused.  The field editor exists only for text cells.

    --Kyle Sluder
  • Great, It would be better to have the appropriate cell type show
    directly in my table.  I made -tableView:dataCellForTableColumn:row in
    my table's delegate, but it is not called.  I am not finding a lot of
    documentation or examples on this. Any suggestions.

    Given I can get it called can this be done selectively for given rows
    or columns and use tableView:tableView objectValueForTableColumn:row
    for those that are text.

    On Jan 19, 2008, at 9:56 AM, Kyle Sluder wrote:

    > Use the NSTableView delegate method
    > -tableView:dataCellForTableColumn:row:, have it return an NSCell
    > subclass of the appropriate type, and either bind it or set its target
    > and action manually.
    >
    > You seem to be confused.  The field editor exists only for text cells.
    >
    > --Kyle Sluder
  • On Jan 19, 2008 12:46 PM, comcast <jhjames3...> wrote:
    > Great, It would be better to have the appropriate cell type show directly in
    > my table.  I made -tableView:dataCellForTableColumn:row in my table's
    > delegate, but it is not called.  I am not finding a lot of documentation or
    > examples on this. Any suggestions.

    Be aware that this is a Leopard-only delegate method; Tiger and below
    simply won't call it.  The more portable option is to subclass
    NSTableColumn and override -dataCellForRow:.

    > Given I can get it called can this be done selectively for given rows or
    > columns and use tableView:tableView objectValueForTableColumn:row for those
    > that are text.

    Just return an NSTextFieldCell for those cells whose data demands a text cell.

    --Kyle Sluder
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today