Problems with custom Cell in NSTableView
Problems with custom Cell in NSTableView
- Subject: Problems with custom Cell in NSTableView
- From: Chris Backas <email@hidden>
- Date: Sun, 14 Jul 2002 22:43:25 -0400 (EDT)
- Priority: Normal
Hello all,
I'm experimenting with supplying my own custom cell to a specific column of an NSTableView, and I'm running into some trouble. (Note, I'm using Java, though I don't think that's relevant to my issue)
I have an NSTableView with two columns, and I want the second column to be an NSPopUpView which is only visible when the row it highlighted. I've subclassed NSPopUpButtonCell, and supplied it to the
NSTableColumn as its dataCell.
In the NSTableView's delegate, I'm catching tableViewWillDisplayCell() calls, and toggling a visible state on my custom cell appropriately, and my custom cell is doing something like this:
public void drawWithFrameInView(NSRect cellFrame, NSView controlView)
{
if (visible)
{
super.drawWithFrameInView(cellFrame,controlView);
};
};
This is actually working, the control is only drawing when the row is highlighted; but I do have a question about my technique, which I'll get to in a moment.
The problem I'm having, is that I can't seem to make the Pop Up view ever display the currently selected item. The items I populate it with are in the list that appears when you click, but it always displays blank, and
I've not been able to convince it to display any text ever. I even tried setting its title explicitly to some nonsense in my constructor, and no-go. There's obviously something I'm missing here, but I can't figure out what.
So, I have two questions:
1) Is it acceptable behavior of my drawWithFrameInView() method to do nothing in the case of the Cell being "invisible"? Or would I be more correct to draw, say, a white rectangle in the NSRect I'm provided? My
method is working, but that doesn't mean it's correct of course ;)
2) What is the correct way of making the NSPopUpButtonCell display the currently selected item? Or, is there something extra I need to do to make it work in the manner I'm using it?
Thanks for any help; and I can read ObjC well enough if anyone's more comfortable replying with examples that way ;)
Chris Backas
_______________________________________________
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.