binding a textfield value like a popup button
binding a textfield value like a popup button
- Subject: binding a textfield value like a popup button
- From: Jim Balhoff <email@hidden>
- Date: Tue, 2 May 2006 15:13:57 -0400
Hi,
I am trying to figure out the best way to let a user select from a
set of objects using a property of those objects (like "name"). This
would be commonly done with an NSPopupButton which has separate
bindings for the contentValues and the selectedObject. In my case I
have an NSTextField which shows the name of an object. I want
someone to be able to type in a new name, but instead of changing the
name of that object, I want to replace that object with one, from a
collection, which has the name the user typed in (I want to do this
so that I can allow the user to quickly select an object by
completing what they type).
I have thought about binding the textfield to the "object" keypath
instead of "object.name" (both made-up for illustration), and then
use a value transformer to display the name in one direction and set
the proper object in the reverse direction. However if I do this
then the textfield will show the wrong value if the name of that
object is edited elsewhere in the application.
NSComboBox would seem to be the right thing to use for autocompleting
from a list of names, however its bindings don't seem to work the
same way as NSPopupButton, in that it directly binds the value of its
textfield to something, instead of the object represented by that value.
Any suggestions would be appreciated.
Thanks,
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden