Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSButtonCell Relating To NSTableView

NSButtonCell Relating To NSTableView
Thread Tools
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Jan 8, 2005, 05:43 PM
 
Hi guys,

I have a NSTableView, and each row is an object. By object I mean a class (called Option) that holds information about a certain row, like a few strings and a few BOOL's.

In my NSTableView, I have 2 columns, one column is set by Interface Builder as a NSButtonCell, and the other is just a normal cell.

As I was saying before, my NSTableView uses an object for each row that holds properties, one property is "isEnabled", which is a BOOL, and this is set by the method "setEnabled:".

Now, I am having trouble understanding how I would go about relating the NSButtonCell to the Object, so that when the button was enabled, the Object in the same row's method, "setEnabled:", would be set to YES, and when the button was disabled, the method would be set to NO.

Any help at all is appreciated :-)

Thanks,
Oliver
     
Dedicated MacNNer
Join Date: Mar 2003
Location: UK
Status: Offline
Reply With Quote
Jan 8, 2005, 06:21 PM
 
You'd need a controller object. Set the target and action of the button cell to the controller, and have that do the work.

Alternatively, Cocoa Bindings may be able to do it.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 8, 2005, 06:48 PM
 
tableView:willDisplayCell:forTableColumn:row: is probably want you're looking for.
     
Forum Regular
Join Date: Aug 2003
Status: Offline
Reply With Quote
Jan 9, 2005, 10:50 AM
 
First: methods aren't set to anything, variables are.

Second: What do you want the button to do when you click it? If you want to call a selector on the object, put an if statement in your -tableView:setObjectValue:forTableColumn:row: that will check if it is that column, and, if so, call that selector.

Third: I would highly recommend trying out key value coding/bindings, they might save you a lot of trouble here.
-- Devin Lane, Cocoa Programmer
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:04 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2