From 51846cbec8dcfe445d7dc03d8b7cdc463d4dbc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 7 Jun 2005 15:07:53 +0000 Subject: added "set"-message svn path=/trunk/externals/bbogart/; revision=3128 --- popup/popup.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'popup/popup.c') diff --git a/popup/popup.c b/popup/popup.c index b6fcd69..8e7274b 100644 --- a/popup/popup.c +++ b/popup/popup.c @@ -483,6 +483,46 @@ static void popup_symselect(t_popup* x, t_symbol *s) } +/* 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( ix_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; ix_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) { @@ -641,6 +681,11 @@ void popup_setup(void) { A_GIMME, 0); + class_addmethod(popup_class, (t_method)popup_set, + gensym("set"), + A_GIMME, + 0); + class_addmethod(popup_class, (t_method)popup_symselect, gensym(""), A_DEFSYMBOL, @@ -660,7 +705,7 @@ void popup_setup(void) { class_setsavefn(popup_class,&popup_save); #endif - post("Popup v0.1 Ben Bogart.\nCVS: $Revision: 1.15 $ $Date: 2005-06-07 08:49:23 $"); + post("Popup v0.1 Ben Bogart.\nCVS: $Revision: 1.16 $ $Date: 2005-06-07 15:07:53 $"); } -- cgit v1.2.1