• 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
reading selectedItem from within dataCellForRow?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reading selectedItem from within dataCellForRow?


  • Subject: reading selectedItem from within dataCellForRow?
  • From: "William Zumwalt" <email@hidden>
  • Date: Mon, 4 Jun 2007 21:44:34 -0500

I have a class subclassed from NSTableColumn which overrides
dataCellForRow: like what's listed below.

My problem is that I want to build the next NSPopUpButtonCell pending
upon the selection of the top NSPopUpButtonCell. So if popupButtonCell
on row 0 has item A selected, then popupButtonCell on row 1 should
only contain and show 2 items (A-B), otherwise, it might list items
A-C.

But I don't know how to make that decision from within this method
because I can't seem to get a handle on the data from here.

- (id) dataCellForRow:(int) row
{
	id textCell = [super dataCellForRow:row];
	NSPopUpButtonCell *pubCell;

	if (row == 0 || row == 1) {
		pubCell = [[NSPopUpButtonCell alloc] init];
		[pubCell setBordered:NO];
		[pubCell setPullsDown:NO];
		[pubCell setFont:[NSFont labelFontOfSize:[NSFont smallSystemFontSize]]];
		[pubCell setControlSize:NSMiniControlSize];
		[pubCell setAlignment:NSLeftTextAlignment];
		[pubCell setEditable:YES];
	}

	if (row == 0) {
		[pubCell addItemWithTitle:@"selection A"];
		[pubCell addItemWithTitle:@"selection B"];
	}
	else if (row == 1) {
		// if "selection A" in row 0 has A selected, then I list 2 items.
		[pubCell addItemWithTitle:@"selection A"];
		[pubCell addItemWithTitle:@"selection B"];

		// otherwise, I might list all 3 items if I could see
             // what is selected from here.
		[pubCell addItemWithTitle:@"selection C"];
	}
	else if (row == 2) {
		[textCell setEditable:NO];
		[textCell setTextColor:[NSColor blackColor]];
	}

	if (row == 0 || row == 1) {
		// these rows are popupButtonCell's
		return pubCell;
	}

	// all other rows are NSTextFieldCell's
	return textCell;
}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: reading selectedItem from within dataCellForRow?
      • From: Yann Bizeul <email@hidden>
    • Re: reading selectedItem from within dataCellForRow?
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: Re: [CoreData] Background Insertion
  • Next by Date: Binding to a "dotted" Key Path in an IBPalette. Should work?
  • Previous by thread: trying to redraw an NSPopupButtonCell (has text on text overlay)
  • Next by thread: Re: reading selectedItem from within dataCellForRow?
  • Index(es):
    • Date
    • Thread