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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to