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

2 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 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

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2011a

Community Treasure Hunt

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

Start Hunting!