• 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, bindings, and auto-complete, oh my!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSComboBox, bindings, and auto-complete, oh my! (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: textDidChange: for several NSTextFields
  • Next by Date: Re: NSTableView and drag and drop
  • Previous by thread: NSComboBox, bindings, and auto-complete, oh my!
  • Next by thread: Handler not called on table cell edit
  • Index(es):
    • Date
    • Thread