[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell in NSTableView problem

From: Andreas Höschler
Subject: Re: NSButtonCell in NSTableView problem
Date: Thu, 29 Nov 2007 12:14:11 +0100

I am pulling my hair out. In a preferences panel I am building a
tableView manually with three columns, one tableColumn with a button

tableColumn = [[NSTableColumn alloc] initWithIdentifier:@"active"];

               NSButtonCell *buttonCell = [[GSButtonCell alloc]
               [buttonCell setButtonType:NSSwitchButton];
               [buttonCell setImagePosition:NSImageOnly];
               [buttonCell setSelectable:NO];
               [tableColumn setDataCell:buttonCell];
               [buttonCell release];

               [(NSCell *)[tableColumn dataCell]

       [tableView addTableColumn:tableColumn];

    [tableView setDataSource:self];
    [tableView setDelegate:self];
    [[tableView tableColumnWithIdentifier:@"active"] setEditable:YES];
    [[[tableView tableColumnWithIdentifier:@"active"] dataCell]
    [[[tableView tableColumnWithIdentifier:@"active"] dataCell]

When I click on the switch I expect

- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn row:(int)row;

to be called but that is not the case. If I doubleclick into one of the
NSTextFieldCells and end editing then the method is called!? What am I
missing. This neither works on GNustep nor on MacOSX so I must be
missing something obvious but I don't see what. Any idea?

Thanks a lot,


I am not sure about that but I think clicking on Checkboxes and
buttons in NSTableView is not considered as "editing".

And, there might be some relation between [buttonCell
setSelectable:NO]; and a cell being editable.

BTW: Why do you use GSButtonCell?

GSButtonCell is my subclass on NSButtonCell. It does nothing right now.

In the meanwhile I figured out why this was not working. I used the wrong NSTableView sublclass that swallowed the mouseDown: event. Having an NSButtonCell in a tableview actually works if

• the buttonCell has  selectable=NO, editable=NO
• the tableColumn has editable=YES

You get unreasonable behaviour, if you set the buttonCell to selectable=YES, editable=YES. This allows you to tab into the cell which is great but

- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(int)row;

is called with wrong values then. :-( But I can live with having to use the mouse for setting the checkbox to state=1 for a while.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]