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
MathWorks Support Team 2012 年 1 月 12 日
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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2011a

Community Treasure Hunt

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

Start Hunting!

Translated by