GUI: Update listbox while editing text

4 visualizaciones (últimos 30 días)
Ingrid
Ingrid el 13 de Feb. de 2013
I want a listbox to be dynamically updated when I change the input in an edit text box. The standard behavior of the GUI is to execute the callback function for the edit text box only after pressing enter or clicking outside the text box, but I want to find a way to execute the function while typing... this should not be so difficult right?
this is what I tried after searching the web:
function edit_text(hObject, eventdata, handles)
addlistener(handles.edit_text,'String',@(hObject,eventdata)updateList(hObject,eventdata,handles));
and then I added the updateList function at the end of the GUI
function updateList(hObject,eventdata,handles)
% code to set listboxInput
set(handles.listbox_invoer,'String',listboxInput);
% Update handles structure
guidata(hObject, handles);
but I get the following error "The specified event is not supported by the object" referring to the line where I try to add the addlistener
Can someone help me on how to use this addlistener, the help documentation is not very explanatory...
  2 comentarios
Ingrid
Ingrid el 15 de Feb. de 2013
It seems I was making it way to difficult... the addlistener function is not needed to solve this problem. If I add
set(handles.figure1,'KeyPressFcn',@myFunctionCustomKeyInput);
set(handles.edit1,'KeyPressFcn',@myFunctionCustomKeyInput);
to the OpeningFcn and then just add the function that updates my listbox to the end of myFunctionCustomKeyInput and it works perfectly! Hope this can inspire others...
Ingrid
Ingrid el 18 de Feb. de 2013
the myFunctionCustomKeyInput requires the findjobj function to work as it needs to read in the text in the edit field even without it having being updated this works great in the matlab environment but fails when using the deploytool to create a standalone executable (which is my final goal) so I would like to ask again if anyone has another solution to this problem: how can you read in the text in the edit field without needing to press enter or click outside the textfield?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Desktop en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by