Last change
on this file since 35 was
19,
checked in by gostiaux, 15 years ago
|
the private files have been moved down to the root folder
|
File size:
880 bytes
|
Line | |
---|
1 | %'update_menu': find an input string in a menu, add it to the menu at the penultimate position if it does not exist
|
---|
2 | %-----------------------------------------------
|
---|
3 | % function menu_str=update_menu(handle,strinput)
|
---|
4 | %
|
---|
5 | % OUTPUT:
|
---|
6 | % menu_str: new menu; cell of strings
|
---|
7 | %
|
---|
8 | % INPUT:
|
---|
9 | % handle: handle of the menu to modify (listbox uicontrol)
|
---|
10 | % strinput: char string to detect or add in the menu
|
---|
11 |
|
---|
12 | function menu_str=update_menu(handle,strinput)
|
---|
13 | menu_str=get(handle,'String');
|
---|
14 | nbmenu=length(menu_str);
|
---|
15 | ichoice=0;%default
|
---|
16 | for imenu=1:nbmenu
|
---|
17 | if isequal(menu_str{imenu},strinput)
|
---|
18 | ichoice=imenu;
|
---|
19 | end
|
---|
20 | end
|
---|
21 | if ichoice==0%the input string does not exist in the menu
|
---|
22 | menu_str{nbmenu+1}=menu_str{nbmenu};%shift the last item ('more...')
|
---|
23 | menu_str{nbmenu}=strinput;
|
---|
24 | set(handle,'String',menu_str)
|
---|
25 | ichoice=nbmenu;
|
---|
26 | end
|
---|
27 | set(handle,'Value',ichoice)
|
---|
Note: See
TracBrowser
for help on using the repository browser.