Is there any way to implement autocomplete function in an edit text with a popup menu?

Hi
I am creating a GUI in which the user searches for a string among other 400 strings. Is there any posibility that the user introduces the first 4 or 5 letters in the edit text and a popup menu displays all the possible matches ?
Thanks a lot!

 채택된 답변

Ingrid
Ingrid 2015년 4월 3일
I have done this two years ago but it was not easy I must say. I finally used a keyPressFunction to detect which strings were typed in and then searched for this string in the cell array and then show the results in a listbox. The desired input could than be selected with the arrows and pressing enter. In my case a partial match was found i.e. can also be in the middle, does not have to start with the letters provided as this was suitable for my application but this can easily be modified.
You can download the source code from
https://www.dropbox.com/s/hrmvunbtwjrd5jb/GUIexampleEditTextFillsList.zip?dl=0
and pick out the relevant code from there. Hope this helps you to spend less time than me. I am sorry for the comments in Dutch, but the code should be self-explantory. If you have any more question you can always contact me.

댓글 수: 6

oh, and I must warn you that the code is not robust to unexpected behaviour i.e. the user should not use the mouse. When you select part of the text with the mouse and overwrite this is not recorded, same as when you change the position of the cursor with your mouse. If you want to be able to do this you should add a check for using the mouse or something, I found it to be to difficult to implement and beyond the scope of my program and therefore just gave a warning to the user.
Could you please indicate if this answer was useful for you?
Thank you so much!
I´m trying to understand your code but it has been really useful ! I appreciate your help .
I don't understand all parts of it myselve so do not bother for the most difficult parts, especiall using the keyPressFunction to remember the string that is typed in I just copied from somwhere on this site (which I always find very useful!)
Cannot reach your dropbox link. Can you please post a snapshot of the code or a readable code here.
Thanks,
Sadhvi.
kindly share the code Please!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Software Development Tools에 대해 자세히 알아보기

태그

질문:

2015년 4월 2일

댓글:

2021년 3월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by