Re: Bindings, TableView, and varying Image based on Selection
Re: Bindings, TableView, and varying Image based on Selection
- Subject: Re: Bindings, TableView, and varying Image based on Selection
- From: Kevin <email@hidden>
- Date: Thu, 15 Feb 2007 07:22:03 -0600
You need to implement tableView:willDisplayCell:forTableColumn:row:
in your NSTableView delegate class.
In there you could determine whether the server row is selected and
alter the image.
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html#//
apple_ref/occ/instm/NSObject/
tableView:willDisplayCell:forTableColumn:row:
Kevin
On Feb 15, 2007, at 1:45 AM, Shehryar Khan wrote:
Here's my setup:
I have an array of Server model objects that I'm displaying in an
NSTableView using an NSArrayController.
My Server model objects implement the following methods
- (NSString *)hostname
- (NSString *)username;
- (NSString *)serverType;
which I have bound to columns in my NSTableView. This all works
great.
I added functionality to display an exclamation mark image in a
column if the server is down. For this I added the following API
to my Server class:
- (BOOL)successfulConnection;
- (void)setSuccessfulConnection:(BOOL)yn;
- (NSString *)connectionStatusImagePath;
The connectionStatusImagePath returns a path to an exclamation mark
image based on the value of successfulConnection and that is
displayed in a new column in the NSTableView. This also works great.
Well almost.
I'd like to vary the image used based on whether that particular
server is selected in the table view. For example if the server is
not selected it will display a grey circle with a white exclamation
mark image. If it's selected, I'd like for it to display a
"highlighted" exclamation mark image which is basically a white
circle with a blue exclamation mark in it. (same functionality as
itunes when it fails to find a song from the user's itunes library
on disk).
Now the question is how to best rig this up.
Is there a way for a model object to register for a notification of
some sort (or perhaps an alternate mechanism) allowing it to know
that it's been selected / unselected? It could then toggle some
flag on it that could then be used within the
connectionStatusImagePath method to vary the image returned back up.
Perhaps I should be going about this differently.
Comments / suggestions appreciated.
thanks!
-shehryar
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40xheadsoftware.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden