NSComboBox Suggestions

  • Hi there



    I'm after some suggestions on implementing some different behavior in
    NSComboBox. Right now the box is tied to a database via a data source
    and works exactly as it should with auto-complete etc. Now we have a
    requirement to have the combo box filter what is in its popup down to
    items that *contain* the string typed into the edit portion of the
    combo, not to just select the first item that starts with the text typed
    into the combo.



    I realize there is an NSSearchField control but this doesn't quite do
    what I want either. I'm also considering attaching a popup menu to an
    NSSearchField control such that the menu is displayed and its contents
    filtered as you type into the search field control. I don't have the
    real-estate for a table control that the search field filters, it has to
    be a pop-up or something like that. Ideally I'd like a 'search-combo'
    control.



    Does the description of what I'm trying to do make sense? I'd like to do
    this in a Mac-like way rather than a Windows-like way that runs on a Mac
    hence the question. Popping a dialog for searching is an option but I'm
    trying to avoid that too.



    Thanks in advance



    Mike
  • Is the behaviour of Apple Mail's To Field what you're after?

    That should give you some clues as to how to make it Mac like,
    although I've never looked at the implementation.

    I'd actually like a To: control like that in one of my apps, but I've
    not been able to find a pre-rolled one (that handles the email
    address retrieval as well).

    On 22 Oct 2007, at 23:03, Mike Cahill wrote:

    > Hi there
    >
    >
    >
    > I'm after some suggestions on implementing some different behavior in
    > NSComboBox. Right now the box is tied to a database via a data source
    > and works exactly as it should with auto-complete etc. Now we have a
    > requirement to have the combo box filter what is in its popup down to
    > items that *contain* the string typed into the edit portion of the
    > combo, not to just select the first item that starts with the text
    > typed
    > into the combo.
    >
    >
    >
    > I realize there is an NSSearchField control but this doesn't quite do
    > what I want either. I'm also considering attaching a popup menu to an
    > NSSearchField control such that the menu is displayed and its contents
    > filtered as you type into the search field control. I don't have the
    > real-estate for a table control that the search field filters, it
    > has to
    > be a pop-up or something like that. Ideally I'd like a 'search-combo'
    > control.
    >
    >
    >
    > Does the description of what I'm trying to do make sense? I'd like
    > to do
    > this in a Mac-like way rather than a Windows-like way that runs on
    > a Mac
    > hence the question. Popping a dialog for searching is an option but
    > I'm
    > trying to avoid that too.
    >
    >
    >
    > Thanks in advance
    >
    >
    >
    > Mike
    >
  • On Oct 22, 2007, at 3:23 PM, Martin Redington wrote:

    > Is the behaviour of Apple Mail's To Field what you're after?
    >
    > That should give you some clues as to how to make it Mac like,
    > although I've never looked at the implementation.
    >
    > I'd actually like a To: control like that in one of my apps, but
    > I've not been able to find a pre-rolled one (that handles the email
    > address retrieval as well).

    NSTokenField (new in 10.4) supports auto-completion drop-downs
    through delegate methods. It holds/edits an array of your custom
    objects. It can display those Apple Mail address field blue lozenges,
    but I just noticed that NSTokenStyle constant NSPlainTextTokenStyle
    (no lozenge) might work for Mike's database app. Even if you don't
    use it, you might get a design pattern idea from it.

    Like Martin implies, for "To field" use, I had to write my own access
    to the Address Book, and other things, that took about 400 lines of
    code and a lot of time. As I recall, ABPicker has a lot more "for
    free" re Address Book access if you don't mind its interface.

    --Paul Collins

    ** Gracion Software LLC                  http://www.gracion.com/
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today