[Gambas-user] Auto select item in new combobox

T Lee Davidson t.lee.davidson at gmail.com
Sun Feb 5 22:30:45 CET 2023


On 2/5/23 04:16, Safiur Rahman wrote:
> Hi
> 
> I used the following code to auto fill text in Combobox. This worked
> well upto gambas 3.17.3.
> 
> 1) Type any alphabet and the related word is shown in combobox. This
> works fine in gambas 3.18.0
> 
> 2) Press down arrow to open pop up list and then type any alphabet.
> The related word is selected. Upto this step gambas 3.18.0 works fine.
> But when I press Return/Enter key then selected item is not returned
> in gambas 3.18.0 (but worked fine till 3.17.3).

Actually, the selected item IS being returned; meaning that ComboBoxItems.Text is being set properly. The issue is that, due to 
the position of ComboBoxItems.Popup, the code undoes this proper functioning by resetting ComboBoxItems.Text after the system 
has set it.

(I uncovered this by placing a Wait statement after ComboBoxItems.Popup and then stepping through the code.)

I changed the Key.Down conditional block to simply this:

[code]
   If Key.Code = Key.Down Then
     ComboBoxItems.Popup

   Else If Key.Code = Key.BackSpace Then
[/code]

That seems to work more like I expected.


However, using either the Backspace or Left-arrow key does not work as I would expect. I haven't come up with a solution for 
that yet as it is due to the fact that ComboBox.Select changes the position of the text cursor, and putting the cursor back 
where is was by setting ComboBox.Pos undoes the selection. I think perhaps a global variable that holds the value of what the 
text cursor position *should* be might be at least part of the answer for that.


-- 
Lee



More information about the User mailing list