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

2 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2011a

Community Treasure Hunt

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

Start Hunting!

Translated by