Re: NSComboBox, bindings, and auto-complete, oh my!
Re: NSComboBox, bindings, and auto-complete, oh my!
- Subject: Re: NSComboBox, bindings, and auto-complete, oh my!
- From: Quincey Morris <email@hidden>
- Date: Mon, 13 Oct 2008 09:52:09 -0700
On Oct 13, 2008, at 08:19, Randall Meadows wrote:
I'm helping someone with a problem concerning NSComboBox whose
contents come from a binding to an NSArrayController, and is set to
autocomplete.
The behavior: Window opens with combobox populated from its
binding. Let's say the contents are
Doe
Jones
Smith
and the textfield contains "Jones". If we start typing "Smi" it
correctly autocompletes to "Smith". HOWEVER, it doesn't *select*
the item "Smith", it *edits* the current selection to be "Smith", so
that the list then ends up as
Doe
Smith
Smith
Currently, there is no custom code behind this, it's all set up via
IB. Do we need to implement a custom -completedString:, and a
custom IB action that selects the list item that satisfies the
completion? Or what?
Your problem is that NSComboBox is a kind of text field, not a kind of
menu. Thus, typing "Smith" (regardless of whether you type it all or
let it autocomplete) changes the value of what the control is bound to
(selection.lastName) from "Jones" to "Smith". The behavior is the same
as if you had used a NSTextField instead of a NSComboBox.
You can get the effect you want by binding the combo box to a
transient text property, and writing an IBAction to find the array
item that matches what was typed (if any).
_______________________________________________
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