Re: How to validate NSComboBoxCell selection
Re: How to validate NSComboBoxCell selection
- Subject: Re: How to validate NSComboBoxCell selection
- From: Steven Kramer <email@hidden>
- Date: Wed, 22 Sep 2004 08:47:43 +0200
Op 22-sep-04 om 0:19 heeft Robbie Haertel het volgende geschreven:
I don't have the address of the person who started this post, but I
too have been contemplating how to do this. The (untested) idea that
I had was to take advantage of the "-(void)tableView:(NSTableView
*)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn
*)aTableColumn row:(int)rowIndex" delegate method. The idea is that
you can edit the attributes of aCell (i.e. set its datasource or get
it and edit it). You could also store a pointer to it so that when
editing is done, you can figure out what selection was made. The
default implementation of NSTableView (in conjunction with
NSTableColumn) stores an instance of an NSCell and then makes a copy
of it for each cell it must display. After making the copy, it then
calls the delegate willDisplayCell method so that you can edit it. If
this is not flexible enough, you could always subclass NSTableColumn
and store an array of cells since it has a method to get the cell for
any given row.
I think you're partly wrong: you get the same cell for each visible
row. You could of course also create a datacell for each row (using
[NSTableColumn dataCellForRow], to solve the original poster's problem.
But that would be a huge waste for large tables.
Right now, changing the combo's menu in
selectionIsChanging/selectionDidChange seems to cut it for me.
willDisplayCell will almost work, I've used that a few times to do this
kind of tweaking but it is more hackish - who knows when another row
needs displaying and changes the menu...
On another note, I think this should actually be an enhancement request
to Apple. It seems very odd that NSComboBoxCell does not send out
(enough) notification and delegate messages.
Regards
Steven
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden