Omnis Technical Note TNGI0012

How to drop down a droplist automatically when entering the dropdown list

For Omnis Studio
By Omnis Technical Support

Problem
Tabbing into a dropdown list or clicking on the dropdown list with the mouse, the dropdown list gets the focus but does not open up automatically; it does not drop down automatically. Pressing the 'Cursor Up' or 'Cursor Down' keyboard buttons displays the previous or next line in the list, if possible, but does not drop down the list. What happens if one wants the list to drop down automatically when that field gets the focus?


Solution
One has to trap the 'On evBefore' event of the drop list as below:

$event method -------------

On evBefore

Queue keyboard event {alt-Down}


This works fine when tabbing into the dropdown list using the TAB key, but some problems occur when the dropdown list gets the focus by clicking on it with the mouse. One is able to choose a list line but the list does not close automatically, it stays open. Only a repeated click on the list will close the list. To work around this problem one has to do the following:

a) In the Action property pane of the dropdown list turn on the mouseevents by setting
    $mouseevents to kTrue.

b) Append the code behind the dropdown list

   $event method -------------

   On evMouseDown

   Quit event handler (Discard event)

   On evBefore

   Queue keyboard event {alt-Down}


The droplist will now act as required.

Search Omnis Developer Resources

 

Hit enter to search

X