Borrar filtros
Borrar filtros

How can I detect if a user has finished making selections from a multiple select listbox in MATLAB 7.12 (R2011a)?

2 visualizaciones (últimos 30 días)
I am enabling multiple selection for the Listbox object and I would like to detect customers' selections based on the release of the CTRL key.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 12 de En. de 2012
The ability to detect key release for the list box object is not available in MATLAB 7.12 (R2011a). The KeyReleaseFCN is a valid callback for the figure objects but it is not triggered when the focus is on another object such as listbox.
There are two workarounds for this issue. The first workaround is to create a push button and ask the user to click this button when he completes the selection.
The second workaround is to implement the WindowKeyReleaseFcn callback function of the figure and manipulate the listbox if it has the focus.
if(gco==handles.listbox1) % the focus is on the list box, please replace listbox1 with corresponding id of your program
if(strcmp(eventdata.Key,'control')) % capture the control key, use '0' for command key in Mac
indices=get(gco, 'value');
items=get(gco, 'string');
set(handles.listbox2, 'string', items(indices)); %copy the items from one listbox to the other one
end
end

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2011a

Community Treasure Hunt

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

Start Hunting!

Translated by