Update of /cvsroot/pure-data/externals/bbogart/popup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20409
Modified Files: popup.c Log Message: added "set"-message
Index: popup.c =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** popup.c 7 Jun 2005 08:49:23 -0000 1.15 --- popup.c 7 Jun 2005 15:07:53 -0000 1.16 *************** *** 484,487 **** --- 484,527 ---- }
+ /* Function to choose value via name/index but without outputting it*/ + static void popup_set(t_popup* x, t_symbol *S, int argc, t_atom*argv) + { + if(!argc)return; + int visible=(x->x_glist)?glist_isvisible(x->x_glist):0; + + if(argv->a_type==A_FLOAT) + { + int i=atom_getint(argv); + if( i<x->x_num_options && i>=0) + { + x->current_selection = i; + if(visible) + sys_vgui(".x%x.c.s%x configure -text "%s"\n", + glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name); + } else { + error("popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options-1, i); + } + } else if(argv->a_type==A_SYMBOL) + { + int i; + t_symbol*s=atom_getsymbol(argv); + /* Compare inlet symbol to each option */ + for(i=0; i<x->x_num_options; i++) + { + if(x->x_options[i]->s_name == s->s_name) + { + x->current_selection = i; + if(visible)sys_vgui(".x%x.c.s%x configure -text "%s"\n", + glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name); + return; + } + } + error("popup: '%s' is not an available option.", s->s_name); + } else + { + pd_error(x, "popup: can only 'set' symbols or floats"); + } + } + /* Function to append symbols to popup list */ static void popup_append(t_popup* x, t_symbol *s, int argc, t_atom *argv) *************** *** 642,645 **** --- 682,690 ---- 0);
+ class_addmethod(popup_class, (t_method)popup_set, + gensym("set"), + A_GIMME, + 0); + class_addmethod(popup_class, (t_method)popup_symselect, gensym(""),