Updating model: NSPopupButtonCell, NSTableView, Bindings
Updating model: NSPopupButtonCell, NSTableView, Bindings
- Subject: Updating model: NSPopupButtonCell, NSTableView, Bindings
- From: Lukas Heiniger <email@hidden>
- Date: Tue, 19 Feb 2008 19:05:02 +0100
Hi All
I'm having problems updating my data model when the user makes a
selection from an NSPopupButtonCell in a NSTableView.
Here's the setup: I have a NSTableView containing three columns. One
of the columns ought to represent integer values from the model, i.e.
it should show some descriptive title instead of the integer value
itself. Of course this also means if the user selects a different
title from the popup menu, the model should be updated to the
represented value.
I've tried two different approaches to achieve this but eventually got
stuck at both of them.
1. Binding the NSPopupButtonCell to the data model
There's a simple example described in http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Tasks/onerelation.html
. The Problem is that they update the model with the actual item that
is selected in the popup, whereas in my case, the title shown in the
popup menu is only a representation of some underlying (integer) value
which should be changed.
What's the best way to do this? Implement a value transformer?
2. Implementing an action to manually update the model when a
selection is made
Here I see some strange behaviour. I'm getting the record which should
be updated by calling [[arrayController selectedObjects] objectAtIndex:
0]. This however seems to return the previously selected record. Let's
say for example row 10 is selected. Now when I click on the
PopupButtonCell in row 3 it changes the selection (visually) but still
updates the value in row 10. It looks like the action is invoked
before the arrayController is informed about the change in selection.
What could I do about this?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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