` Autocomplete (Sean Cameron ) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Par2: Autocomplete
2007-12-31 -- Sean Cameron
 
You can use one of the third party accessories available, or implement it yourself (which isn't too hard). 1) Use a Combo control 2) In Event:DroppingDown set a flag to indicate that the list has dropped, and populate the queue: droppedDown = 1 Select(?Mail:ToList, 1) 3) In Event:NewSelection if the droppedDown flag is set or the keycode is 37 or 39 (the left and right arrow keys) cycle out. This is to preserve the normal behaviour when the control is being edited like a normal entry control. Otherwise populate the list with matching entries by looping through the file based on the key that contains the lookup field. You can use Instring() or the FuzzyMatch class to determine when to break out of the loop. 4) In Event:ScrollDown select the entry in the list: if (?Mail:ToList{prop:listfeq}){prop:selected} < Records(SuggestionQ) Select(?Mail:ToList{prop:listfeq}, (?Mail:ToList{prop:listfeq}){prop:selected} + 1) end 5) Similarly in Event:Scrolldown: if (?Mail:ToList{prop:listfeq}){prop:selected} > 1 Select(?Mail:ToList{prop:listfeq}, (?Mail:ToList{prop:listfeq}){prop:selected} - 1) end 6) In Event:Accepted get the selected entry to populate into the field and set the flag back to zero: Get(SuggestionQ, 0+(?Mail:ToList{prop:listfeq}){prop:selected}) ! Do any processing needed here, and assign the field from the queue Mail.ToList = Clip(SuggestionQ.description) droppedDown = 0 In the case above SuggestionQ contains all the "suggestions", the combo field is ?Mail:ToList and the field being filled is Mail:ToList. In my case it's a bit more complex as the field can contains multiple entries, seperated by commas or semi colons, and entries can contains names and email address or even combinations thereof. The bulk of the code in my case is processing the list, matching it up with a second queue that the individual addresses are parsed into, and building a new string to assign etc. It's a bit more complex when a any number of different strings can mean the same thing .


Today is April 19, 2024, 6:28 pm
This article has been viewed 35109 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: