• 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: custom view in NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom view in NSTableView


  • Subject: Re: custom view in NSTableView
  • From: Sarat Kongara <email@hidden>
  • Date: Mon, 13 Aug 2001 16:45:17 -0400

Thanks that works very well.

On Saturday, August 11, 2001, at 11:14 AM, Brian Hill wrote:

You don't want to return an actual button from the table datasource.

The way to go about it is to set the dataCell of the column to an
NSButtonCell, and then return an NSNumber representing the value the
control should take for that column.

To wit:

//do this somewhere in the setup code, like awakeFromNib or something
[[[tableView
tableColumnWithIdentifier:@"ButtonColumnIdent"]setDataCell:buttonCellInstance]
;

The table column retains the buttonCell instance so you don't need to
hold onto it.

Then in the objectValueForTableColumn... method do something like this:

if([[tableColumn identifier]isEqualToString:@"ButtonColumnIdent"])
{
//return either:
return [NSNumber numberWithInt:0];
//or this:
return [NSNumber numberWithInt:1];
}



Responding to user clicks on the button is the same, but in reverse...8-)

I didn't understand what you meant by the above line. I set a target and
action for the button using setAction and setTarget. But how do I make
the button the sender of the message.

If the signature of the action method is (void) toggleSwitch: (id)
sender, the sender that the method is getting is the NSTableView and not
the switch button. Also the same method gets called for each button, I
am trying to use a side effect of the button clicking, the row in the
table gets selected when I click the button and I can use the row number
to find out which button is clicked. What's the better way to handle
this.

Sarat


  • Follow-Ups:
    • Re: custom view in NSTableView
      • From: Brian Hill <email@hidden>
References: 
 >Re: custom view in NSTableView (From: Brian Hill <email@hidden>)

  • Prev by Date: Re: CLI calls
  • Next by Date: ObjectAlloc -- not able to use with debugger launched app?
  • Previous by thread: Re: custom view in NSTableView
  • Next by thread: Re: custom view in NSTableView
  • Index(es):
    • Date
    • Thread