• 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
Coloring a Row in a NSTableView.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coloring a Row in a NSTableView.


  • Subject: Coloring a Row in a NSTableView.
  • From: Joshua Garnham <email@hidden>
  • Date: Sun, 10 Jan 2010 08:01:49 +0000 (GMT)

What I am looking to do is set the background color of the selected row in an NSTableView when a I button is clicked.
I've seen other cases where people have used tableView:willDisplayCell:forTableColumn:row: and setBackgroundColor: but I don't think that will work in my situation where I want it to happen when a button is clicked.

I know that I can find the selected row with NSTableView's selectedRow method and set the Background color for a cell with setBackgroundColor:, but what I don't know how to do is get from a NSInteger for the selected row to an NSCell to set the background color of.
Here's what I have so far:
- (void)tableView:(NSTableView *)aTableView
  willDisplayCell:(id)aCell
   forTableColumn:(NSTableColumn *)aTableColumn
              row:(NSInteger)rowIndex {
    NSLog(@"Coloring Method Begun");
    int selectedRow = [outlineView selectedRow];
    if (selectedRow == nil) {
    }else {
        if (clicked == YES) {
            [aCell setBackgroundColor:[NSColor lightGrayColor]];
            clicked = NO;
            NSLog(@"Coloring Method Ended");
        }else {
        }
    }
}

- (IBAction)colorize:(id)sender{
    NSLog(@"Click Method Begun");
    clicked = YES;
    NSIndexSet *selectedRowSet = [outlineView selectedRowIndexes];
    NSIndexSet *selectedColumnSet = [outlineView selectedColumnIndexes];
    [outlineView reloadDataForRowIndexes:selectedRowSet columnIndexes:selectedColumnSet];
    NSLog(@"Click Method Ended");
}

But it seems that the delegate method is never triggered.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: What gets automatically localized?
  • Next by Date: iPhone interruption with OpenAL?
  • Previous by thread: Re: [self frame].size.width reporting incorrectly
  • Next by thread: iPhone interruption with OpenAL?
  • Index(es):
    • Date
    • Thread