source: trunk/src/update_menu.m @ 456

Last change on this file since 456 was 236, checked in by sommeria, 14 years ago

correct Matlab PIV, remove call to image tool box. Improve menu of uvmat VelType? (replacement of buttons)

File size: 811 bytes
RevLine 
[8]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
12function menu_str=update_menu(handle,strinput)
13menu_str=get(handle,'String');
14nbmenu=length(menu_str);
[236]15ichoice=find(strcmp(strinput,menu_str),1);
16if isempty(ichoice)%the input string does not exist in the menu
[8]17    menu_str{nbmenu+1}=menu_str{nbmenu};%shift  the last item ('more...')
18    menu_str{nbmenu}=strinput;
19    set(handle,'String',menu_str)
20    ichoice=nbmenu;
21end
22set(handle,'Value',ichoice)
Note: See TracBrowser for help on using the repository browser.