-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathfcnCallback_cmd_ClearSelected_from_CommandLine.m
48 lines (44 loc) · 1.48 KB
/
fcnCallback_cmd_ClearSelected_from_CommandLine.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function fcnCallback_cmd_ClearSelected_from_CommandLine()
%% About:
% This function is used to clear the currently selected command in the
% command line interface
% Copyright: Mohammad SAFEEA, 20th-July-2018
% show confirmation dialog box
quest='Are you sure you want to delete the selected command / commands from the command line!!!';
title='Confirmation request!!!';
btn1='Apply';
btn2='Cancel';
defbtn=btn2;
answer = questdlg(quest,title,btn1,btn2,defbtn);
switch answer
case btn1
% delete selected items
h=findobj(0,'tag','txt_CommandLine');
selectedItems = get(h, 'Value');
nomOfSelectedItems=max(max(size(selectedItems)));
if nomOfSelectedItems>0
set(h, 'Value',1) % very important, fix the bug when deleting the last element of the listbox
st=get(h,'String');
n=max(max(size(st)));
st1=[];
counter=0;
for j=1:n
flagOfNestedLoop=false;
for i=1:nomOfSelectedItems
index=selectedItems(i);
if j==index
flagOfNestedLoop=true;
end
end
% if the item is not selected, then added to the new list
if flagOfNestedLoop==false
counter=counter+1;
st1{counter}=st{j};
end
end
set(h,'String',st1);
end
case btn2
% nothing
end
end