Force combo box list to drop?

Paul Mulroney pmulroney at logicaldevelopments.com.au
Thu Oct 17 05:39:46 UTC 2024


Hi Scotte,

I ended up creating a headed list box on the fly.  I have some auto-complete code that handles the magic for me, so it's easy to apply to any field.  For example, we have a suburb field, so we lookup the suburb based on a list of 18000 lines::

> On evBefore
> Do ioAutoComplete.$initialise($cobj().$dataname,clSuburbs) ## Initialise with our pre-defined list.  This just makes it easier later on.
> Do $cobj.$keyevents.$assign(kTrue) ## Turn key events on
> 
> On evAfter ## Event Parameters - pClickedField, pClickedWindow, pMenuLine, pCommandNumber, pRow
> If clSuburbs.$linecount<>0 ## We have suburbs in our lookup
> Do $cobj.$keyevents.$assign(kFalse) ## Turn key events off
> Calculate $cwind.$objs.clSuburbs.$visible as kFalse ## Hide the list of matches
> If clSuburbs.$line<>0 ## We have a match
> # Do nothing
> Else ## Expand and then try searching again
> Do voSuburb.$ConvertSuburb(fContacts.coPSUBRB) Returns fContacts.coPSUBRB ## Expand abbreviations
> Do ioAutoComplete.$BinarySearch($cobj().$dataname,fContacts.coPSUBRB,0) Returns vnLine ## Lookup the full entry
> Calculate clSuburbs.$line as vnLine
> End If
> Calculate fContacts.coPSTATE as clSuburbs.suSTATE
> Calculate fContacts.coPPCODE as clSuburbs.suPCODE
> Do $cwind.$objs.COPSUBRB.$redraw() ## Redraw the field
> Do $cwind.$objs.COPSTATE.$redraw() ## Redraw the field
> Do $cwind.$objs.COPPCODE.$redraw() ## Redraw the field
> End If
> 
> On evKey
> Do ioAutoComplete.$Key($cobj()) Returns vnLine ## Process this event.  Return the line number in the list so we can lookup the other entries.
> Calculate clSuburbs.$line as vnLine
> If vnLine<>0
> Set reference vrThisField to $cfield
> Calculate $cwind.$objs.clSuburbs.$visible as kTrue ## Show the list of matches
> Calculate $cwind.$objs.clSuburbs.$vscroll as vnLine
> End If
> Quit method 

With 18000 lines in the list, searching the list is painfully slow.  So, we implemented a binary search that executes in moments.  

Regards
Paul.



> On 17 Oct 2024, at 12:15 pm, Scotte Meredith <spomacguy at gmail.com> wrote:
> 
> You could trap the key events and put them together in a string, and ach rime doing a $search in the list to select the line. 
> 
> 
> Sent from my iPad
> 
>> On Oct 16, 2024, at 7:47 PM, Paul Mulroney <pmulroney at logicaldevelopments.com.au> wrote:
>> 
>> Hi Scotte,
>> 
>> That seems to work.  Now, I'd like to make it so that as the user continues to type, the current line in the list is updated and the position scrolled so we can see it.
>> 
>> Is that possible?  Is it something like calculate $cwind.$objs.comboboxfieldname.$vscroll as listname.$line ?
>> 
>> Regards
>> Paul.
>> 
>> 
>> 
>> 
>>> On 17 Oct 2024, at 10:19 am, Scotte Meredith <spomacguy at gmail.com> wrote:
>>> 
>>> Maybe try a Queue Click on the field.
>>> 
>>> 
>>> Sent from my iPad
>>> 
>>>>> On Oct 16, 2024, at 6:53 PM, Paul Mulroney <pmulroney at logicaldevelopments.com.au> wrote:
>>>> 
>>>> Hi $all,
>>>> 
>>>> Is there a way to make the droplist for a combo to drop down using command or notation?  I'm trying to make an auto-complete field and there's a number of matches - it would be cool to show them in a droplist underneath the field and I thought a combo box might be the easiest way to get there.
>>>> 
>>>> Regards
>>>> Paul.
>>>> 


A will is a dead giveaway.
-- 
Paul W. Mulroney                                            We Don't Do Simple Pty Ltd 
pmulroney at logicaldevelopments.com.au       Trading as Logical Developments
www.logicaldevelopments.com.au                   ACN 161 009 374 
Ph: +61 8 9458 3889                                       86 Coolgardie Street
                                                                         BENTLEY  WA  6102





More information about the omnisdev-en mailing list