Re: NSComboBox and bindings
Re: NSComboBox and bindings
- Subject: Re: NSComboBox and bindings
- From: Joakim Danielson <email@hidden>
- Date: Fri, 28 May 2004 01:25:57 +0200
On 2004-05-27, at 11.23, Ivan Myrvold wrote:
I have mostly got the bindings for NSComboBox working now. If I select
a title from the list, the title is stored in my setter method. I want
the value (stored in a different array) to be stored instead.
I have a model object (oppgave_combo) with an access method
(displayarray) which returns an array of strings to be displayed as
the items in the NSComboBox.
The same model object have another method (valuearray) which returns
the values to be stored as a result of selecting an item.
This last one I don't quite know how to bind to the NSComboBox.
Value Selection: (of the NSComboBox's binding):
> content = oppgave_combo.displayarray [File's Owner
(MyWindowController)]
> contentValues
> value = oppgave_combo.value [File's Owner (MyWindowController)]
This works fine, The NSComboBox is populated with the displayarray,
and selecting an item sets the instance variable "value" of the model
object "oppgave_combo".
But how do I bind the NSComboBox, so that the values stored in the
_valuearray is stored instead of the title?
I tried to bind contentValues like this:
> contentValues = oppgave_combo.valuearray [File's Owner
(MyWindowController)], but then I get the following message:
2004-05-27 11:18:12.926 Partos[5585] Binding contentValues of object
<NSComboBox: 0x7fcfac0> ignored: Key path (currently bound as
oppgave_combo.valuearray) needs to have the content key path
(oppgave_combo.displayarray) as prefix
2004-05-27 11:18:12.978 Partos[5585] Binding contentValues of object
<NSComboBox: 0x7fcfac0> ignored: Key path (currently bound as
oppgave_combo.valuearray) needs to have the content key path
(oppgave_combo.displayarray) as prefix
With contentValues you select the attribute of the objects in your
array that you what to be displayed in the NSComboBox. So the error
means that it can't find the attribute "oppgave_combo.valuearray" in
the objects (NSString objects I assume) in your array
oppgave_combo.displayarray.
I think that the only way you can use your valuearray is by creating an
outlet in oppgave_combo and connect it to your combo box and go from
there. As Fritz said below " It's a text field, not a menu".
Joakim
Pe 26. mai. 2004 kl. 18.48 skrev Fritz Anderson:
The experiment that I found works is:
-- Bind the contentValues to arrangedObjects.name
-- Bind the value to some property of the NSObjectController that
owns the array from which the arrangedObjects were drawn. This has to
be independent of the array and the selection of the
NSArrayController, because (I repeat) NSComboBox doesn't really deal
in selection from a list except as a convenience in filling in a text
field. It's a text field, not a menu.
-- In the setter method for the value property, modify the
contentValues array, if desired.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.