Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding to NSButtonCell in NSTableView [SOLVED]



Oh no.

Stupidity has prevented me from realizing that it is indeed possible to change the type of data cell in an NSTableView in IB directly. Just for the record: in IB, drag any desired cell type (e.g. a check- box) from the "Cocoa Data" palette onto the table column. It's that easy. Works perfectly... :-P

Thanks everyone who pointed this out to me.

Cheers,
Knud

Am 11.04.2006 um 10:36 schrieb Jonathan Fewtrell:


Knud

If you assign the button to the column in IB it works fine for me. In your case is it necessary to do it programatically?

Regards
Jon

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



------------------------------------------------- Knud Möller, MA +353 - 91 - 495086 Digital Enterprise Research Institute National University of Ireland, Galway Institiúid Taighde na Fiontraíochta Digití Ollscoil na hÉireann, Gaillimh


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

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.