How can I detect if a user has finished making selections from a multiple select listbox in MATLAB 7.12 (R2011a)?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
Réponse acceptée
MathWorks Support Team
le 12 Jan 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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!