• 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: NSPopUpButtonCell as NSTableView header problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButtonCell as NSTableView header problem


  • Subject: Re: NSPopUpButtonCell as NSTableView header problem
  • From: PGM <email@hidden>
  • Date: Wed, 26 Jul 2006 22:33:52 -0400

Dear Ender,

I have had similar problems trying to set a switchButton in a tableColumn header. I cannot really help you but I can tell you about my experiences; they might prevent you from having the same problems as me.

-It seems to me that clicking on a column header, the headerview does not really forward any events to the cell, but simply calls setState: . Using a switchbutton as a headerCell, using more or less the same code as yours, results in the button being switched on when the column is selected and off when the column is deselected. This makes sense in a way, but was not really the behaviour I was hoping for. I do not know how NSPopUpButtonCell responds to setState: but I guess it doesn't do much.

-There are some threads in the archives that also report the problem with the last, empty column having the same headerCell as the one that really should be the last. An annoying side effect of this ghost column is that it appears to be an incomplete copy of the last real column, and takes some variables from that last one. When I subclassed NSHeaderCell, the ghost column invariably made my program crash because an NSImage object that I used in my subclass (perfectly balancing retain & release) was send extra release messages from the ghost column. I guess the only solution is to add an extra empty column yourself with the standard headerCell or to make sure your columns are wide enough to fill the whole tableView so that the ghost column does not appear.

-I also tried to make a subclass of NSButtonCell that implements the NSTextAttachmentCell protocol and place that cell into an attributedString, and send that attributedString to the (default) headerCell with setObjectValue: . This put a nice button in the header and I could programmatically change its status but it did not respond to mouseEvents, and always was disabled (greyed out).

Good luck, Patrick

On Jul 26, 2006, at 21:24, Ender Wiggins wrote:

Anyone have an idea here of what I've done so far? Still not working correctly.

On 7/22/06, Ender Wiggins <email@hidden> wrote:
I'm still trying to make NSPopUpButtonCell's appear in my
NSTableViewHeader. The title of my first popup item appears, but it
has a few problems.

#1 Clicking on the header doesn't drop down the items. Though I do get
the mouseDown event from overriding my NSTableHeaderView.
#2 I can't drag on the edges of the column to resize them.
#3 I have four columns and four headers (which I see during debug),
although there are 5 headers that appear but it's the 4th that looks
like it's being shown twice and not refreshed.

I subclassed NSTableHeaderView and add it to my NSTableView here.

- (void) awakeFromNib
{
NSTableHeaderView *currentTableHeader = [tableView headerView];
DataTableHeader *dataTableHeader = [[DataTableHeader alloc] init];


        [dataTableHeader setFrame:[currentTableHeader frame]];
        [dataTableHeader setBounds:[currentTableHeader bounds]];

        [tableView setHeaderView:dataTableHeader];
}

I think at this point I have something wrong, this is where I create
my table column headers but I don't know how to put the
NSPopUpButtonCell's into my NSTableHeaderView. Below they are just put
directly into the NSTableView by doing a setHeaderCell.

- (int) createColumns
{
        NSTableColumn *column;
        NSPopUpButtonCell *headerCell;

        ...

        for (int i = 0; i < count; i++) {
                NSString *col = [columnItems objectAtIndex:i];

headerCell = [[NSPopUpButtonCell alloc] initTextCell:col];
[headerCell setControlSize:NSMiniControlSize];
[headerCell setBordered:NO];
[headerCell setPullsDown:YES];
[headerCell setFont:[NSFont labelFontOfSize:
[NSFont systemFontSize]]];


                [headerCell addItemWithTitle:@"Item A"];
                [headerCell addItemWithTitle:@"Item B"];

column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]];
[column setHeaderCell:headerCell];
[column sizeToFit];


                [tableView addTableColumn:column];
        }

        ...
}

Don't really know what needs to be added here. But I do get mouse down events.

@implementation DataTableHeader

- (void)mouseDown:(NSEvent *)theEvent
{
        NSLog(@"mouseDown event");
}

@end

Anyone know how to get the NSPopUpButtonCell into the table headers if
what I've got is on the right track?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ 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
References: 
 >NSPopUpButtonCell as NSTableView header problem (From: "Ender Wiggins" <email@hidden>)
 >Re: NSPopUpButtonCell as NSTableView header problem (From: "Michael Ash" <email@hidden>)
 >Re: Re: Re: NSPopUpButtonCell as NSTableView header problem (From: "Ender Wiggins" <email@hidden>)

  • Prev by Date: Coredata and NSOutlineView / NSTreeController
  • Next by Date: Re: NSTextView, style, and weird Core Data issue
  • Previous by thread: Re: Re: Re: NSPopUpButtonCell as NSTableView header problem
  • Next by thread: Writing application without Interface Builder
  • Index(es):
    • Date
    • Thread