Page 1 of 1
Autocompleting Popup Box
Posted: Thu Aug 17, 2006 9:22 pm
by Xombie
This code is sufficiently different from the original autocompleting stuff that I thought it needed it's own category. The code contains the original completing routines as well as the enhanced popup box code. You can use this code as an update to the non-popup box if you like since I cleaned up the routines.
Basically this code will take an array and an editgadget and will popup a little window with any matching items. You can control the number of characters it will match on and you can update the array at any time if the items change.
It's simply used like ...
Code: Select all
ac_SetAutocomplete(#EditTest, @Array03(), 3)
... where Array03 is an array of strings and the number 3 means we're only matching on 3 or more characters. This will be 0 if you don't want the popup box.
The code needs to be bug tested badly so I'm putting it out there for anyone that's interested

I expect full reports back ~_~
Let me know when you find any bugs or if I need to change some behavior.
http://www.seijin.net/Storage/Code/Autocomplete.zip
Take it easy!

Posted: Thu Aug 17, 2006 10:04 pm
by Flype
that's pretty cool xombie.
as you ask us, here is a little bug :
in main.pb
in the editorgadget '#EditTest' / Array03()
when i type [Return] [Return] char,
selecting CHARFORMAT2 in the popup,
and finally [Tab] it displays 'chCHARFORMAT2 '
Posted: Thu Aug 17, 2006 10:51 pm
by Xombie
I'm on it. Didn't check different lines
Thanks for trying it for me ^_^
Posted: Fri Aug 18, 2006 3:49 pm
by Progi1984
Very good idea to create a new windows which contains the listview !!!!
Bug :
- If you create two lines in the array with the same word, two are in the array
- the case recognition are not used ?
- if i use the bottom arrow, that goes down in the listview but if you use the enter key, that create a linebreak on the editorgadget
- I use this array
Code: Select all
;/ Create Items for the editor
Array03(0) = "Openw"
Array03(1) = "Openw"
Array03(2) = "Openwin"
Array03(3) = "Openwa"
Array03(4) = "Openwindow"
Array03(5) = "Word"
Array03(6) = "Orgasme"
with
Code: Select all
ac_SetAutocomplete(#EditTest, @Array03(), 1)
And i write w in th editorgadget, i have no listview
Good job, when you (and me f you want) have resolved bugs, could i add this functionnality to LibEditorPlus ?
Posted: Fri Aug 18, 2006 3:57 pm
by Flype
@progi
Array03(6) = "Orgasme"
oh yes, fred, i want this feature.

Posted: Fri Aug 18, 2006 5:04 pm
by srod
Nice work (as always) Xombie.
Using your example, in the first string type "jackoo" and then try and delete with the baskspace key. It stops on jack (which is of course one of the searched for words).
Is this right?
Posted: Fri Aug 18, 2006 5:48 pm
by Xombie
Thanks ^_^
No, that's a bug. It happened before and I fixed it but I guess I put it right back

I'll add it to my list and have a fix out in a few hours. I think

Posted: Fri Aug 18, 2006 8:52 pm
by Xombie
Alright, I believe I have those bugs fixed. Take a look and let me know what I missed.
I'm going to pretty much totally redo the code as it's horribly messy and chaotic. Bad coding habits for projects like these. I just start with an idea and keep building on it. Makes for quicker results in small projects but not great code >_>
http://www.seijin.net/Storage/Code/Autocomplete.zip
..: Edit :.. By the way, what did you mean about 'case', progi?
Posted: Fri Aug 18, 2006 8:57 pm
by Flype
i meant CaseSensitive :
openwindow() <> OpenWindow()
Posted: Fri Aug 18, 2006 9:15 pm
by Xombie
Progi1984 mentioned it... I thought <_<
I suppose I'm looking at this from a programming stand point. Should I allow both "TEST" and "Test" in the list and allow the user to select either one? I'm going for a case insensitive approach and not displaying any duplicate items.
Also, I'm going to break off this popup list code on it's own and make it only for editor gadgets (rich edit controls) - any complaints on that? Should it also be allowed for string gadgets (edit controls) ?
Posted: Mon Aug 21, 2006 8:11 am
by Progi1984
If i set
Code: Select all
ac_SetAutocomplete(#EditTest, @Array03(), 1)
,
when i have three characters in word, the autocompletion list isn't launched.
Posted: Mon Aug 21, 2006 4:21 pm
by Xombie
That's weird. I just tested it and it worked over here. I checked with both ...
Code: Select all
ac_SetAutocomplete(#EditTest, @Array03(), 1)
... and ...
Code: Select all
ac_UpdateArray(#EditTest, @Array03(), 1)
... and both worked fine for completing with or without 3 letters already in place. Maybe give me a very specific example? I might be misunderstanding what you're meaning.
Also, I'm reworking the whole code for the popup list so I may have some new stuff to replace this.
Posted: Tue Aug 22, 2006 8:03 am
by Progi1984
A very specific example
Code: Select all
1. Write a beginning of word
2. The autocompleting is launched
3. Choose your word
4. By example, the length of your word is 5.
5. Now, you delete the last character
6. and the autocompleting is not launched but in the PB ide, YES !
Posted: Tue Aug 22, 2006 8:28 pm
by Xombie
Well, here's the reworked code. It only works for rich edit gadgets and only provides for the popup list functionality. Otherwise, it should be similar to the older code. The public functions are ...
Code: Select all
SetGadgetPopList(#EditTest, @Array01(), 3)
UpdatePopList(#EditTest, @Array01(), 1)
RemoveGadgetPopList(-1)
... those. See if it reacts a little better than before. Hopefully it does
Also, Progi1984, I still couldn't recreate the error you had. See if this code has the same problem and let me know, please.
http://www.seijin.net/Storage/Code/PopList.zip
Posted: Wed Aug 23, 2006 8:05 am
by Progi1984
I haven't no problems now.
Very good work !!!!! Very good work !!!!!