Re: NSComboBox
Re: NSComboBox
- Subject: Re: NSComboBox
- From: Sandor Szatmari <email@hidden>
- Date: Wed, 25 Jul 2018 19:40:40 -0400
I have done stuff like this just using NSTextField. You can connect delegate
methods to supply the array of suitable strings to select from that match the
‘prefix’ the user types in. For every character the user types I recalculate
the array of completions. You can filter a very long list of completions very
quickly. I don’t have the code in front of me but I can post something
tomorrow if this sounds like an avenue you haven’t considered yet.
I think it was a combination of:
-controlTextDidChange:
-(NSArray *)control:(NSControl *)control textView:(NSTextView *)textView
completions:(NSArray *)words forPartialWordRange:(NSRange)charRange
indexOfSelectedItem:(NSInteger *)index
I found that the non obvious part was setting the pointer ‘index’ to -1 or
something like that to indicate that no selection was made yet. This caused
the entire list of possible completions to be presented. Then everything worked
as expected. If you know the index of the string you want to autocomplete to
you set ‘index’ to that, well…, index.
Sandor
> On Jul 25, 2018, at 18:56, Keary Suska <email@hidden> wrote:
>
> NSComboBox is just a suped-up NSTextField, so you can some sort of validation
> so you can prevent the user from exiting the field if they don’t enter an
> acceptable value. The most basic approach is delegation and doing the check
> in -control:textShouldEndEditing:
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>> On Jul 25, 2018, at 4:40 PM, Casey McDermott <email@hidden> wrote:
>>
>> I forgot to mention that the lists may contain 10,000s of items. Maybe
>> 100,000s.
>> Typing to select from NSPopUpButton works OK for short lists. I just made a
>> test
>> popup with 300 items and it's already awkward. 10K would be absurd.
>>
>> These are business records, and users may data enter hundreds a day. They
>> want
>> to tab, type a few letters to select a customer, tab to the next field, type
>> a bit to
>> select an inventory item, etc. Type a customer that doesn't exist and it
>> should beep
>> and ignore the keystrokes. If they need to enter a new customer, it's a
>> right-click,
>> then a panel to enter more than just the name.
>>
>> Our current interface does use popup buttons for some things, but people
>> complain
>> about them. They don't want to take hands off keyboard. We plan to convert
>> those
>> to combo boxes so it can be completely mouseless.
>>
>> That "disambiguating field" article by Tog may be on one of the developer
>> CDs.
>> I can't find it online. It explained this use case very well, and interface
>> to solve it.
>> It was a major reason why we switched from Excel templates to a C++ app.
>> NSComboBox is close, but we need it confined to existing items.
>>
>> Thanks,
>>
>> Casey McDermott
>>
>> Turtle Creek Software
>> http://www.turtlesoft.com
>> 607 220-4514
>>
>> --------------------------------------------
>> On Wed, 7/25/18, Jens Alfke <email@hidden> wrote:
>>
>> Subject: Re: NSComboBox
>> To: "Casey McDermott" <email@hidden>
>> Cc: email@hidden
>> Date: Wednesday, July 25, 2018, 2:51 PM
>>
>>
>>
>> On
>> Jul 25, 2018, at 10:45 AM, Casey McDermott <email@hidden>
>> wrote:
>> The
>> goal is to auto-fill an account from what they type, and
>> ignore typing if not a match.
>>
>> That sounds like the regular behavior
>> of NSPopUpButton: after clicking to pop up the menu, you can
>> type-select items from it.
>> (Although it doesn't ignore
>> mismatches, it just selects the closest item.)
>> —Jens
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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
_______________________________________________
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