Menu

#29 A smarter AICompletingTextField

closed
None
5
2012-09-08
2004-07-16
No

Hi Adium developers,

I love Adium; just started using it as my primary IM client a
few weeks ago.

Anyway, one thing irritated me a little bit: if I use File
->New Chat (File -> New Message in versions <=0.62), the
text field is the initialFirstResponder, so I naturally begin
typing in it first. If I type a name that initially matches a
name in my AIM buddy list (which is the first account
selected in the pop-up), the completion field kicks in and
changes the text to match the my buddy's name. And of
course, if I continue typing, it adjusts the entries as
appropriate. So far, so good.

What annoyed me was that the auto-completion
completely replaced my already-typed text, effectively
changing the case of what I had typed. Every auto-
completing text field that I can remember keeps the case of
the text you type the same as how you typed it. So I poked
around in the source code until I found the
AICompletingTextField class, and modified it to keep the text
that the user typed, and only append the
remaining characters from the auto-completion value (a
more standard behavior, IMHO).

The new behavior is relatively simple: as you type, it keeps
what you've typed and just adds the additional characters
(without changing the case of what you've typed). If you
press Enter or Tab (thus invoking textDidEndEditing:), it
searches for a matching value (case-insensitive). If it
succeeds, it replaces the entered string with the matches
one, effectively "correcting" the case. If it doesn't find
one, it doesn't change the entered text. If you do not press
Enter or Tab, but instead click on another control,
textDidEndEditing: does not get called, and so the text is left
just as you entered it (so, if the user wants to type a
string that differs only by case from somebody in his or her
buddy list, they can do so without the case getting changed
to match the buddy list).

Whew, hopefully that describes the behavior
adequately. Personally, I have not noticed any negative side
effects of this change, so I am proposing that this change be
officially included. I have attached a diff; hopefully I did it
correctly.

Discussion

  • Brent Redeker

    Brent Redeker - 2004-07-16

    AICompletingTextField patch

     
  • Evan Schoenberg

    Evan Schoenberg - 2004-08-04

    Logged In: YES
    user_id=669684

    Heya :) Not sure how I missed seeing this patch was submitted - sorry
    for the delay; we usually try to look at such things fairly quickly.

    I'll play with this in the next couple days and either accept it or provide
    some
    feedback.

     
  • Brent Redeker

    Brent Redeker - 2004-08-05

    Logged In: YES
    user_id=364292

    No problem on the delay.

    My proposed fix is pretty simple and doesn't seem to have
    negative side-effects (IMHO, of course). Take that how you will,
    considering how incomplete my knowledge of the entire Adium
    source is. Feedback is very welcome (I'm just a wannabe Cocoa
    hacker for now).

    Actually, the work on meta-contacts may lead to a changes to the
    New Chat dialog that will supersede my change. If not, I hope the
    patch makes it into Adium - then I won't have to worry about
    patching my CVS checkout all the time :-)

     
  • Evan Schoenberg

    Evan Schoenberg - 2004-08-05

    Logged In: YES
    user_id=669684

    I like. Made one small change before committing - added a check
    against the completion's length to be 100% sure that it's longer than the
    input text, as stringFromIndex: with an index equal to the last index of
    the completion string could potentially be problematic and at best would
    return @"" and therefore be wasteful. At the same time, retrieved the
    [userValue length] once and then used that int in multiple places -
    avoiding redundant calls is always good.

    That's OCD nitpicking :) Thanks for a nice patch. Even if the New Chat
    dialogue changes (and it likely will), as the improvement is to the
    autocompleting text field the changes remain relevant.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.