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

Re: Checkboxes in an NSTableView


  • Subject: Re: Checkboxes in an NSTableView
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 26 Feb 2004 19:39:06 -0500

on 2004-02-26 6:31 PM, Brant Sears at email@hidden wrote:

> I have an NSTableView that has a column of checkboxes. I'm attempting to
> programatically toggle the value of some of these boxes. I have code that
> acquires a reference to the cell by calling:
>
> NSCell* theCell = [myTableColumn dataCellForRow: theRowIndex];
>
> So, now I have an NSCell * which seems to be an NSButtonCell pointer which
> is what I would expect. I've attempted to call performClick on it. I've also
> tried calling [theCell setIntValue: NSOnState] (or NSOffState) which also
> doesn't work.
>
> I've even tried to enable or disable the button cell which apparently I
> can't do either.
>
> Any ideas on how I can accomplish the goal of programatically toggling the
> checkbox cells?

To change the value of the checkbox in the cell programmatically, change the
value in the datasource, then call reloadData. As a result, your
tableView:objectValueForTableColumn:row: datasource protocol method will be
called, and that's where you want to set the value to be displayed to
whatever value is now in the datasource.

In general, all programmatic changes to values in datasource-based views
should be effectuated in the datasource, then displayed in the view via the
view's -...objectValue... datasource protocol method by calling reloadData.

This is different from controlling the appearance of the cell. The
tableView:willDisplayCell:forTableColumn:row: delegate method gives you a
reference to the cell that will be displayed. It does this for every cell in
the table, just before it is displayed. In the delegate method, you can
call, for example, [cell setEnabled:YES], or whatever, to control how the
cell will appear. But the value to displayed in the cell should be
controlled through the -...objectValue... Method and reloadData.

The same applies to outline views, although some of the method names are a
little different.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Checkboxes in an NSTableView (From: Brant Sears <email@hidden>)

  • Prev by Date: Re: Sheets
  • Next by Date: Re: How to remove focus from a window control?
  • Previous by thread: Re: Checkboxes in an NSTableView
  • Next by thread: How to remove focus from a window control?
  • Index(es):
    • Date
    • Thread