|
Post by metro on Feb 25, 2020 4:07:35 GMT -5
Is there a way to select an item from a long list in a combobox using the enter key? Thanks in advance
|
|
|
Post by tsh73 on Feb 25, 2020 5:32:32 GMT -5
I got an idea moving event from combo box to button (default button to catch ENTER key)
So I got combo box selected - then press F4 to open it - then select then OOPS Enter doesn't fire event then combo is open But still I can close it with ESC and then Enter works.
So I got rid of button and used GetAsyncKeyState function to catch Enter key. It works for me.
dim a$(100)
nomainwin
for i = 1 to 100 a$(i) = "item ";i next
combobox #win.combo, a$(),[doCombo],10,10,120,200
open "Combobox Demo" for window as #win #win "trapclose [quit]" #win.combo "selectindex 1" #win.combo "setfocus"
timer 100, [enterkey] wait
[enterkey] CallDLL #user32, "GetAsyncKeyState",_VK_RETURN as long,fKeyPress as long if fKeyPress <0 then 'if Enter or Return key is pressed #win.combo "selection? sel$" notice "You chose ";sel$ end if wait
[quit] close #win end
[doCombo] wait
as an idea, if you have more then one control on a form, you better check if combobox is actually active Probably with API GetFocus
|
|
|
Post by metro on Feb 25, 2020 8:31:23 GMT -5
Thanks Anatoly, for some reason it does not work for me. I will play with it some more. I am using Linux+Wine so maybe that is an issue ....appreciate the help
|
|