I’m trying to replicate an HTML SELECT element (drop-down-list or combobox) in Flash (AS3).
In most browsers, when you have one in focus and you type something, the combobox will try to find the value within its options and show the closest one. I was wondering what kind of algorithm is used for that.
I don’t think its Levenshtein or similar since it only works with the beginning of the string.
I’m thinking that it works by keeping a buffer of what has been written, and tries to find a string starting with that… if it doesn’t find anything, it clears the buffer, and searches a string beginning with the last character pressed.
I already prototyped this, and it works quite ok, with one caveat… In HTML, when you repeatedly press the same key, it will rotate between all options starting with that character. I think I could fix this, but was wondering if someone has already done it, to compare the algorithms… its turning into quite a complex code to test and debug, and I’m not sure I’m covering all the possibilities…
The reaction of form widgets to keyboard interaction is not standardised and different browsers don’t agree. This is always an issue when creating ersatz form controls from script.
This feature comes from Windows and is quite unintuitive. The exact rule isn’t that exactly, is quite obscure, and gives different results in IE and Opera versus the other browsers.
IMO this behaviour is highly undesirable. Since no average user is going to be able to predict how the rule works, I personally would leave it out and simply select the first option to match the typed leftstring. This is easier for you to code and easier for the user to understand.