Message: 2
Date: Mon, 10 Apr 2006 16:25:06 +0100
From: Knud M?ller <email@hidden>
Subject: Binding to NSButtonCell in NSTableView
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=ISO-8859-1; delsp=yes;
format=flowed
Hi,
I have seen this question pop at least twice in the archives, but
always without an answer:
I want to bind a table column to a BOOL field ("active") of an array
objects. That works fine: I set up the bindings in IB, and without
any further modifications, TRUE gets displayed as "1" and FALSE as
"0". Then I programatically change the table column' s data cell to
an NSButtonCell, type NSSwitchButton, using the code below:
// set the "active" column cell to be an NSButtonCell:
NSButtonCell *activeCell = [[NSButtonCell alloc] init];
[activeCell setButtonType: NSSwitchButton];
[activeCell setTitle: @""];
[activeCell setEnabled: YES];
[activeColumn setDataCell: [activeCell autorelease]];
That works fine to a degree. The BOOLs now get rendered correctly as
checkboxes (either on or off). However, I cannot manipulate the
checkboxes; clicking them has no effect. If I double-click, I
suddenly get a text field editor. Does changing the column's data
cell break the binding? I thought so and tried to do a programatic
binding:
[activeCell bind: @"value"
toObject: activePluginsArrayController
withKeyPath: @"selection.active"
options: nil];
However, no result. Which steps am I missing here? Any help
appreciated.
Cheers,
Knud