• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSComboBox and bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComboBox and bindings


  • Subject: Re: NSComboBox and bindings
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 26 May 2004 11:48:28 -0500

The problem is that a combo box is not a popup menu:

A popup menu represents a choice of an immutable value from an immutable array of choices.

A combo box represents an arbitrary value, which is coordinated with an array of choices, which the programmer may make mutable -- for instance by adding each new entry in the field to the array. There is no question of selecting an indexed member of the list, as it is permissible to enter a string that isn't a member of the list.

Binding the value of an NSComboBox to a property of an NSArrayController's selection would therefore be expected to edit the property of the selected item itself. It's hard to see what else to expect, as the mutability and content of the contentValues are at the option of the programmer.

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.

-- F


On 26 May 2004, at 9:02 AM, Ivan Myrvold wrote:

I see exactly the same problem. I didn't see any answer of this posting. Have anyone an answer to this?

Ivan

Pe 17. des. 2003 kl. 23.28 skrev David Webster:

Hi list,

Am I doing something wrong or is this a bug? The following is reduced to the simplest I can make it.

I have a NSComboBox a NSArrayController and a model class with a "name" instance variable with KVC compliant accessors. I have set the following:

NSArrayController's - Object Class Name: to the model class
NSComboBox's bindings to:-
content ->
BindTo: NSArrayController
Controller Key: arrangedObjects
Model Key Path:

contentValues ->
BindTo: NSArrayController
Controller Key: arrangedObjects
Model Key Path: name

value->
BindTo: NSArrayController
Controller Key: selection (Note: have tried all other combinations as well)
Model Key Path: name

I also have an Add button hooked up to the Add: action method on NSArrayController
Repeat 3X {
Hit Add, edit the combo field followed by <cr>
}
If I drop down the list I have, for example

Item1
Item2
Item3 <- this is highlighted as it was the last item entered

If I NSLog() the contents of the NSArrayController I get the same three strings - everything OK so far!
Now if I select Item1 from the list, for example, the text field shows Item1 as expected but if I drop the list down again I have

Item1
Item2
Item1

if I output the contents of the NSArrayController I also have the above.
It would seem that the NSArrayController is updating the last selected position but with the newly selected list item.
A bug or just me?

Thanks
David
_______________________________________________
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.


Ivan C Myrvold
OrtopediService AS
Mob. 913 16 356
Tlf. 38 14 45 93
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSComboBox and bindings
      • From: Ivan Myrvold <email@hidden>
    • Re: NSComboBox and bindings
      • From: Ivan Myrvold <email@hidden>
References: 
 >Re: NSComboBox and bindings (From: Ivan Myrvold <email@hidden>)

  • Prev by Date: Re: simple telnet-like networking in cocoa
  • Next by Date: Re: Copy/Paste not working from keyboard
  • Previous by thread: Re: NSComboBox and bindings
  • Next by thread: Re: NSComboBox and bindings
  • Index(es):
    • Date
    • Thread