From a41c3f46bfe9897f79647ae6189aec9069905392 Mon Sep 17 00:00:00 2001
From: Thomas O Fredericks <mrtof@users.sourceforge.net>
Date: Mon, 21 Dec 2009 04:01:41 +0000
Subject: Added focusing and indicator options to pmenu

svn path=/trunk/externals/tof/; revision=12843
---
 test/pmenu-help.pd |  85 +++++++++++-----
 test/pmenu.c       | 114 +++++++--------------
 test/pmenu_w.h     | 290 +++++------------------------------------------------
 3 files changed, 120 insertions(+), 369 deletions(-)

(limited to 'test')

diff --git a/test/pmenu-help.pd b/test/pmenu-help.pd
index 1775fab..323ca23 100644
--- a/test/pmenu-help.pd
+++ b/test/pmenu-help.pd
@@ -1,29 +1,66 @@
-#N canvas 1164 0 617 484 10;
-#X obj 210 274 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
+#N canvas 120 25 756 631 10;
+#X obj 221 187 key;
+#X msg 126 222 clear;
+#X obj 221 213 sel 65;
+#X text 267 213 <- Shift+A will open the menu;
+#X msg 47 63 add a bb ccc dddd eeeee;
+#X obj 45 498 print;
+#X msg 230 320 2;
+#X msg 261 321 3;
+#X text 201 62 add items;
+#X obj 265 417 r \$0pmenu;
+#X obj 332 422 bng 15 250 50 0 \$0pmenu empty empty 17 7 0 10 -262144
 -1 -1;
-#X obj 228 213 key;
-#X msg 158 188 clear;
-#X obj 228 239 sel 65;
-#X text 252 275 <- Shift+A will open the menu;
-#X text 225 5 <- Select a folder here;
-#X msg 61 151 add a bb ccc dddd eeeee;
-#X obj 61 431 print;
-#X obj 252 80 tof/folderpanel;
-#X text 324 311 bg fg hi;
-#X msg 204 325 2;
-#X msg 366 334 colors green;
-#X msg 246 321 3;
-#X msg 158 225 add a;
-#X obj 61 392 tof/pmenu black white red;
-#X text 201 414 Outlets: symbol index dump;
-#X obj 376 192 soundfiler;
-#X connect 0 0 14 0;
-#X connect 1 0 3 0;
+#X text 353 420 <- you can pop the menu from any gui by sending a bang
+to \$0pemenu;
+#X msg 291 320 -1;
+#X msg 224 287 colors green purple grey;
+#X obj 45 459 tof/pmenu 1 1 black white red;
+#X text 298 536 3: background color (#000000 html or tk colors);
+#X text 296 551 4: foreground color (#000000 hmtl or tk colors);
+#X text 298 566 5: highlight color (#000000 html or tk colors);
+#X text 222 257 values can be tk colors(red \, blue \, etc) or html
+colors (#ffffff);
+#X text 221 241 colors: background foreground highlight;
+#X text 297 507 2: focus the item that was last selected when the menu
+pops. On (1) by default.;
+#X text 296 476 1: display the indicator (the little bullet next to
+item that was last selected). On (1) by default.;
+#X obj 38 18 cnv 15 400 30 empty empty empty 20 12 0 14 -261234 -66577
+0;
+#X text 40 31 tags: ui;
+#X text 38 18 description: pops a menu;
+#X obj 300 458 cnv 15 400 15 empty empty empty 20 12 0 14 -257985 -66577
+0;
+#X text 303 456 Creation arguments:;
+#X msg 87 153 add \$1;
+#X obj 87 130 cyclone/tosymbol;
+#X msg 87 107 with spaces;
+#X text 84 87 Adding items with spaces;
+#X obj 113 180 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
+-1 -1;
+#X text 132 176 Pop the menu;
+#X text 249 179 You can assign any key to pop the menu (Shift+A) in
+this case.;
+#X text 322 319 Select and output a menu item by index;
+#X msg 276 349 set a;
+#X msg 290 371 symbol a;
+#X text 346 370 Select an item by name and output it;
+#X text 320 349 Select an item by name without outputing it;
+#X text 85 501 Output: index name;
+#X connect 0 0 2 0;
+#X connect 1 0 14 0;
 #X connect 2 0 14 0;
-#X connect 3 0 0 0;
+#X connect 4 0 14 0;
 #X connect 6 0 14 0;
-#X connect 10 0 14 0;
-#X connect 11 0 14 0;
+#X connect 7 0 14 0;
+#X connect 9 0 14 0;
 #X connect 12 0 14 0;
 #X connect 13 0 14 0;
-#X connect 14 0 7 0;
+#X connect 14 0 5 0;
+#X connect 27 0 14 0;
+#X connect 28 0 27 0;
+#X connect 29 0 28 0;
+#X connect 31 0 14 0;
+#X connect 35 0 14 0;
+#X connect 36 0 14 0;
diff --git a/test/pmenu.c b/test/pmenu.c
index ee6f2ae..458a0b6 100644
--- a/test/pmenu.c
+++ b/test/pmenu.c
@@ -30,45 +30,29 @@
 
 
 
+
+
 typedef struct _pmenu
 {
      t_object x_obj;
 
      t_glist * x_glist;
-     //t_outlet* out2;
-     //int x_rect_width;
-     //int x_rect_height;
+
      t_symbol*  callback;
 	
-     //int x_height;
-     //int x_width;
-	 
      int current_selection;
      int x_num_options;	 
      t_symbol* bg_color;
      t_symbol* fg_color;
      t_symbol* hi_color;
      t_symbol* co_color;
-     //int saveitems;
-     
-     //t_symbol* send;
-     //t_symbol* receive;
-     
-     //int send_set;
-     //int receive_set;
-     
-     //t_symbol* s_empty;
-     //t_symbol* s_;
-     //t_symbol* x_name;
-	
+    
      t_symbol** x_options;
      int        x_maxoptions;
-     //int 		visible;
-     
-     //t_symbol** current_options;
-
-     //int created; //1 when menu is created
-     //int x_disabled; /* when disabled, graphical chosing is prohibited */
+   
+      int indicator;
+      int focusing;
+   
 } t_pmenu;
 
 #include "pmenu_w.h"
@@ -77,7 +61,6 @@ static void pmenu_output(t_pmenu* x)
 {
   
   
-  pmenu_w_activate(x);
   
   t_atom atoms[2];
   SETFLOAT(atoms,x->current_selection);
@@ -240,9 +223,12 @@ static int pmenu_set_float(t_pmenu* x, t_floatarg item) {
 	if( (i < x->x_num_options) && (i >= 0)) {
 		x->current_selection = i;
 		//if(pmenu_w_is_visible(x)) pmenu_w_text(x,x->x_options[x->current_selection]);
+		pmenu_w_activate(x);
          return 1;
 	} else {
-         return 0;
+		x->current_selection = -1;
+		pmenu_w_activate(x);
+        return 0;
    }
 	
 }
@@ -255,7 +241,8 @@ static void pmenu_float(t_pmenu* x, t_floatarg item)
 	if ( pmenu_set_float(x,item) ) {
 		pmenu_output(x);
 	} else {
-		pd_error(x,"pmenu: expecting value between 0 and %i",x->x_num_options);
+		
+		//pd_error(x,"pmenu: expecting value between 0 and %i",x->x_num_options);
 	}
 
 	DEBUG(post("iselect end");)
@@ -271,9 +258,12 @@ static int pmenu_set_symbol(t_pmenu* x, t_symbol *s) {
 	  if(x->x_options[i]->s_name == s->s_name) {
 		    x->current_selection = i;
 			//if(pmenu_w_is_visible(x)) pmenu_w_text(x,s);
+            pmenu_w_activate(x);
 	        return 1;
        }
 	}
+	x->current_selection = -1;
+	pmenu_w_activate(x);
 	return 0;
 }
 
@@ -359,51 +349,33 @@ static void *pmenu_new(t_symbol *s, int argc, t_atom *argv)
     int i;
 	char buf[256];
 
-     //x->x_glist = NULL;
-    //x->visible = 0;
-    //x->created = 0;
-    
-    //x->x_glist = (t_glist*)NULL;
 
-    //x->x_height = 25;
     x->current_selection = -1;
 
     x->x_maxoptions=10;
     x->x_options=(t_symbol**)getbytes(sizeof(t_symbol*)*x->x_maxoptions);
-    //x->current_options=(t_symbol**)getbytes(sizeof(t_symbol*)*x->x_maxoptions);
+ 
     x->x_num_options = 0 ;
-     //x->x_options[0] = gensym("");
-     
-    //x->x_width = 124;
-    //x->x_height = 25;
+  
+    x->indicator = 1;
+    x->focusing = 1;
+  
     
     // These should match the default colors in pmenu_colors
     x->bg_color = gensym("grey90");
     x->fg_color = gensym("black");
     x->hi_color = gensym("grey95");
     x->co_color = gensym("black");
-    //x->saveitems = 0;
-    
-    //x->s_empty = gensym("empty");
-    //x->s_ = gensym("");
-    
-    //x->send = x->s_empty;
-    //x->receive = x->s_empty;
-    //x->send_set =0;
-    //x->receive_set =0;
-    
-   
-
-    //x->x_disabled=0;
-    
-    
+      
 	
-    if (argc > 4) argc = 4;
+    if (argc > 6) argc = 6;
     switch(argc){ 
-    case 4: if ((argv+3)->a_type==A_SYMBOL) x->hi_color = atom_getsymbol(argv+3);	
-	case 3: if ((argv+2)->a_type==A_SYMBOL) x->hi_color = atom_getsymbol(argv+2);	
-	case 2: if ((argv+1)->a_type==A_SYMBOL) x->fg_color = atom_getsymbol(argv+1);	
-	case 1: if ((argv)->a_type==A_SYMBOL) x->bg_color = atom_getsymbol(argv);
+    case 6: if ((argv+5)->a_type==A_SYMBOL) x->co_color = atom_getsymbol(argv+5);	
+	case 5: if ((argv+4)->a_type==A_SYMBOL) x->hi_color = atom_getsymbol(argv+4);	
+	case 4: if ((argv+3)->a_type==A_SYMBOL) x->fg_color = atom_getsymbol(argv+3);	
+	case 3: if ((argv+2)->a_type==A_SYMBOL) x->bg_color = atom_getsymbol(argv+2);
+	case 2: if ((argv+1)->a_type==A_FLOAT) x->focusing = atom_getfloat(argv+1);
+	case 1: if ((argv)->a_type==A_FLOAT) x->indicator = atom_getfloat(argv);
       break;
     }
 
@@ -420,7 +392,7 @@ static void *pmenu_new(t_symbol *s, int argc, t_atom *argv)
    
    pmenu_w_menu(x,CREATE);
    pmenu_w_apply_colors(x);
-   if (argc > 5) pmenu_add(x,&s_list,argc-5,argv+5);
+   //if (argc > 5) pmenu_add(x,&s_list,argc-5,argv+5);
 
 
 DEBUG(post("pmenu new end");)
@@ -439,16 +411,7 @@ void pmenu_setup(void) {
 				
 	class_addmethod(pmenu_class, (t_method)pmenu_callback,
 								  gensym("callback"),A_DEFFLOAT,0);
-	/*							  
-	class_addmethod(pmenu_class, (t_method)pmenu_send,
-								  gensym("send"),A_DEFSYMBOL,0);
-								  
-	class_addmethod(pmenu_class, (t_method)pmenu_receive,
-								  gensym("receive"),A_DEFSYMBOL,0);
-								  
-	class_addmethod(pmenu_class, (t_method)pmenu_saveitems,
-								  gensym("saveitems"),A_FLOAT,0);
-		*/		  
+	
 	class_addmethod(pmenu_class, (t_method)pmenu_add,
 								  gensym("add"), A_GIMME,0);
 	
@@ -457,11 +420,7 @@ void pmenu_setup(void) {
 						  
 	class_addmethod(pmenu_class, (t_method)pmenu_colors,
 								  gensym("colors"),A_GIMME,0);
-		/*								 
-    class_addmethod(pmenu_class, (t_method)pmenu_size,
-								  gensym("size"),A_GIMME,0);
-    */
-    
+	
         class_addmethod(pmenu_class, (t_method)pmenu_set,
                                     gensym("set"),A_GIMME,0);
 	
@@ -471,12 +430,7 @@ void pmenu_setup(void) {
 
 
 
-    //class_setwidget(pmenu_class,&pmenu_widgetbehavior);
-
-    //class_setsavefn(pmenu_class,&pmenu_save);
-
-
-	post("pmenu v0.01 by tof");
+	post("pmenu v0.02 by tof");
 }
 
 
diff --git a/test/pmenu_w.h b/test/pmenu_w.h
index 713b47e..b1ff496 100644
--- a/test/pmenu_w.h
+++ b/test/pmenu_w.h
@@ -2,37 +2,38 @@
 #define UPDATE 0
 #define CREATE 1
 #define DESTROY 2
-/*
-static int pmenu_w_is_visible(t_pmenu* x) {
-	
-	return ( x->x_glist != NULL);
 
-}
-
-static void pmenu_w_text(t_pmenu* x, t_symbol* s) {
-	
-	sys_vgui(".x%x.c itemconfigure %xLABEL -text {%s} \n",
-                 glist_getcanvas(x->x_glist), x, s->s_name);
-                 
-
-}
-*/
+#define COLUMNBREAK 30
 
 static void pmenu_w_activate(t_pmenu* x){
 	//sys_vgui("$%xw activate %i\n", x,x->current_selection);
-	sys_vgui("set %xradio %i\n",x,x->current_selection); 
+	//if ( x->indicator) {
+		sys_vgui("set %xradio %i\n",x,x->current_selection); 
+	//} else {
+		
+	 //  sys_vgui("set %xradio %i\n",x,-1); 
+	//}
 }
 
 
 static void pmenu_w_clear(t_pmenu* x){
 	sys_vgui("$%xw delete 0 end \n", x);
-	sys_vgui("set %xradio %i\n",x,-1); 
+	//sys_vgui("set %xradio %i\n",x,-1); 
+	x->current_selection = -1;
+	pmenu_w_activate(x);
 }
 
 static void pmenu_w_additem(t_pmenu* x, t_symbol *label, int i) {
-	
+	if ( x->indicator) {
 	sys_vgui("$%xw add radiobutton -label \"%s\" -command {select%x \"%d\"} -variable %xradio -value %d \n",
                    x, label->s_name, x, i,x,i);
+                   
+			   } else {
+	sys_vgui("$%xw add command -label \"%s\" -command {select%x \"%d\"} \n",
+                   x, label->s_name, x, i,x,i);
+			   }
+	if ( i == COLUMNBREAK ) sys_vgui("$%xw entryconfigure %i -columnbreak  true \n",x,i);
+			   
 }
 
 static void pmenu_w_apply_colors(t_pmenu* x) {
@@ -40,72 +41,8 @@ static void pmenu_w_apply_colors(t_pmenu* x) {
 	sys_vgui("$%xw configure -background \"%s\" -foreground \"%s\" -activeforeground \"%s\" -activebackground \"%s\" -selectcolor \"%s\"\n", x,
 	x->bg_color->s_name,x->fg_color->s_name,x->fg_color->s_name,x->hi_color->s_name,x->fg_color->s_name);
 	
-	/*
-	sys_vgui(".x%x.c.s%x configure -background \"%s\" -foreground \"%s\" -activeforeground \"%s\" -activebackground \"%s\"\n", 
-	x->x_glist, x, x->bg_color->s_name,x->fg_color->s_name,x->fg_color->s_name,x->hi_color->s_name);
 	
-	sys_vgui(".x%x.c.s%x.menu configure -background \"%s\" -foreground \"%s\" -activeforeground \"%s\" -activebackground \"%s\"\n", 
-	x->x_glist, x, x->bg_color->s_name,x->fg_color->s_name,x->fg_color->s_name,x->hi_color->s_name);
-
-    sys_vgui(".x%x.c itemconfigure  %xR -outline \"%s\"\n", x->x_glist, x,x->co_color->s_name);
-    * */
-}
-
-
-
-/*
-static void pmenu_w_draw_inlets(t_pmenu *x, t_glist *glist, int draw, int nin, int nout)
-{
-	
- // outlets
-     int n = nin;
-     int nplus, i;
-     nplus = (n == 1 ? 1 : n-1);
-     DEBUG(post("draw inlet");)
-     for (i = 0; i < n; i++)
-     {
-	  int onset = text_xpix(&x->x_obj, glist) + (x->x_width - IOWIDTH) * i / nplus;
-	  if (draw==CREATE) {
-	       sys_vgui(".x%x.c create rectangle %d %d %d %d -outline blue -tags {%xo%d %xo}\n",
-			glist_getcanvas(glist),
-			onset, text_ypix(&x->x_obj, glist) + x->x_height + 1 ,
-			onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_height+2,
-			x, i, x);
-	  } else if (draw==UPDATE) {
-	       sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
-			glist_getcanvas(glist), x, i,
-			onset, text_ypix(&x->x_obj, glist) + x->x_height +1,
-			onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_height+2);
-		} else {
-			
-			sys_vgui(".x%x.c delete %xo\n",glist_getcanvas(glist),x); // Added tag for all outlets of one instance 
-		}
-     }
- // inlets 
-     n = nout; 
-     nplus = (n == 1 ? 1 : n-1);
-     for (i = 0; i < n; i++)
-     {
-	  int onset = text_xpix(&x->x_obj, glist) + (x->x_width - IOWIDTH) * i / nplus;
-	  if (draw==CREATE) {
-	       sys_vgui(".x%x.c create rectangle %d %d %d %d -outline blue -tags {%xi%d %xi}\n",
-			glist_getcanvas(glist),
-			onset, text_ypix(&x->x_obj, glist)-2,
-			     onset + IOWIDTH, text_ypix(&x->x_obj, glist)-1,
-			x, i, x);
-	  } else if (draw==UPDATE) {
-	       sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
-			glist_getcanvas(glist), x, i,
-			onset, text_ypix(&x->x_obj, glist)-2,
-			onset + IOWIDTH, text_ypix(&x->x_obj, glist)-1);
-	  } else {
-		  sys_vgui(".x%x.c delete %xi\n",glist_getcanvas(glist),x); // Added tag for all inlets of one instance
-	  }
-     }
-     DEBUG(post("draw inlet end");)
-     
 }
-*/
 
 
 static void pmenu_w_menu(t_pmenu *x, int draw)
@@ -117,7 +54,7 @@ static void pmenu_w_menu(t_pmenu *x, int draw)
 	   // Create menu 
 	   //sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -justify left 
 	   // Create a variable to store a pointer to the menu, create the menu, create a variable to store the selected item
-      sys_vgui("set %xw .%x ; menu $%xw -relief solid -tearoff 0; set %xradio 0 \n",x,x,x);
+      sys_vgui("set %xw .%x ; menu $%xw -relief solid -tearoff 0; set %xradio -1 \n",x,x,x);
       int i;
 	  for(i=0 ; i<x->x_num_options ; i++)
         {
@@ -126,7 +63,10 @@ static void pmenu_w_menu(t_pmenu *x, int draw)
         }
   } else if ( draw == DESTROY) {
 	  //x->created = 0;
+	
+	 
 	  sys_vgui("destroy $%xw \n",x);
+	  
   }
 
   //DEBUG(post("id: .x%x.c.s%x", glist, x);)
@@ -134,198 +74,18 @@ static void pmenu_w_menu(t_pmenu *x, int draw)
 }
 
 
-
-
-/*
-static void pmenu_w_draw(t_pmenu *x, t_glist *glist, int draw)
-{
-	
-	 int xpos = text_xpix(&x->x_obj,glist);
-     int ypos = text_ypix(&x->x_obj,glist);
-	 t_canvas* canvas = glist_getcanvas(glist);
-  //t_canvas *canvas=glist_getcanvas(glist);
-  DEBUG(post("drawme start");)
-
-  DEBUG(post("drawme %d",draw);)
-     if (draw==CREATE) {
-		// Base
-		
-		sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xR -fill \"%s\" -outline \"%s\" \n",
-	     canvas, xpos, ypos ,
-	     xpos + x->x_width, ypos + x->x_height,
-	     x,x->bg_color->s_name,x->co_color->s_name); 
-	     
-	    // Text
-	    sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w -fill \"%s\" -tags %xLABEL -width %i \n" ,
-             canvas, xpos+2, ypos+x->x_height/2,
-             "",x->fg_color->s_name, x, x->x_width-2,x->x_height -2); 
-             //-font {{%s} -%d %s}
-             //x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight
-     } else if (draw==UPDATE) {
-		 // Base
-		sys_vgui(".x%x.c coords %xR %d %d %d %d\n",
-	     canvas, x, 
-	     xpos, ypos ,
-	     xpos + x->x_width, ypos + x->x_height );
-		// Text
-		sys_vgui(".x%x.c coords %xLABEL %d %d\n",
-             canvas, x, xpos+2,ypos+x->x_height/2);
-     } else {
-		 // Base
-		sys_vgui(".x%x.c delete  %xR\n",canvas,x);
-		// Text
-		sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
-		
-		DEBUG(post("erase done");)
-       }
-		
-  DEBUG(post("drawme end");)
-}
-*/
-/*
-static void  pmenu_w_resize(t_pmenu* x) {
-	
-	//sys_vgui(".x%x.c itemconfigure %xS -width %i -height %i \n", x->x_glist, x,x->x_width-1,x->x_height-1);
-	
-	
-	pmenu_w_draw(x,x->x_glist,UPDATE);
-	canvas_fixlinesfor(x->x_glist,(t_text*) x);
-}
-*/
-/*
-static void pmenu_w_getrect(t_gobj *z, t_glist *owner,
-    int *xp1, int *yp1, int *xp2, int *yp2)
-{
- // DEBUG(post("getrect start");)
-
-    int width, height;
-    t_pmenu* s = (t_pmenu*)z;
-
-    width = s->x_width;
-    height = s->x_height;
-    *xp1 = text_xpix(&s->x_obj, owner) ;
-    *yp1 = text_ypix(&s->x_obj, owner) ;
-    *xp2 = text_xpix(&s->x_obj, owner) + width  ;
-    *yp2 = text_ypix(&s->x_obj, owner) + height ;
-  
-   // DEBUG(post("getrect end");)
-}
-
-
-static void pmenu_w_displace(t_gobj *z, t_glist *glist,
-    int dx, int dy)
-{
-    t_pmenu *x = (t_pmenu *)z;
-    DEBUG(post("displace start");)
-    x->x_obj.te_xpix += dx;
-    x->x_obj.te_ypix += dy;
-   
-      //pmenu_w_draw_handle(x,glist,UPDATE);
-      //pmenu_w_draw_inlets(x, glist, UPDATE, 1,1);
-      pmenu_w_draw(x, glist, UPDATE);
-      canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
-    
-    DEBUG(post("displace end");)
-}
-
-static void pmenu_w_select(t_gobj *z, t_glist *glist, int state)
-{
-     DEBUG(post("select start");)
-
-     t_pmenu *x = (t_pmenu *)z;
-     
-		 
-		  //sys_vgui(".x%x.c itemconfigure %xhandle -fill %s\n", glist, 
-	     //x, (state? "blue" : x->fg_color->s_name));
-		 
-       if (state) {
-		    //pmenu_w_draw_handle(x,glist,CREATE);
-		    pmenu_w_draw_inlets(x, glist, CREATE, 1,1);
-		    //pmenu_w_disable(x,1);
-       }
-       else {
-		   //pmenu_w_disable(x,0);
-		 //pmenu_w_draw_handle(x,glist,DESTROY);
-         pmenu_w_draw_inlets(x,glist,DESTROY,1,1);
-         
-       }
-     
-
-     DEBUG(post("select end");)
-}
-
-
-// Standard delete function
-static void pmenu_w_delete(t_gobj *z, t_glist *glist)
-{
-
-   canvas_deletelinesfor(glist, (t_text *)z);
-
-}
-
-// Standard create function      
-static void pmenu_w_vis(t_gobj *z, t_glist *glist, int vis)
-{
-    t_pmenu* x = (t_pmenu*)z;
-    t_rtext *y;
-    DEBUG(post("vis start");)
-    DEBUG(post("vis: %d",vis);)
-    if (vis) {
-		x->x_glist = glist;
-		
-	    pmenu_w_draw(x, glist, CREATE);
-    } else {
-		x->x_glist = NULL;
-		//if ( x->created ) pmenu_w_menu(x, glist,DESTROY);
-		pmenu_w_draw(x, glist, DESTROY);
-    }
-
-    DEBUG(post("vis end");)
-}
-*/
-
 static void pmenu_w_pop(t_pmenu *x) {
 	
 	if (x->x_num_options > 0) {
 			 //if ( x->created == 0 )  pmenu_w_menu(x, glist, CREATE);
-			 if ( x->current_selection != -1 ) {
+			 if ( x->current_selection != -1 && x->focusing) {
 				 sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] %i\n",x,x->current_selection);
 			 } else {
-				sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] 1\n",x);
+				sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] \n",x);
 		   	}
 		 }
 	
 }
 
-/*   
-static int pmenu_w_click(t_pmenu *x, struct _glist *glist,
-    int xpos, int ypos, int shift, int alt, int dbl, int doit) {
-		
-		DEBUG(post("x: %i,y: %i,shift: %i, alt: %i, dbl: %i, doit: %i",xpos,ypos,shift,alt,dbl,doit);)
-		
-		//if (doit) sys_vgui("tk_popup $%xw %i %i \n",x,100,100);
-		
-		if (doit && x->x_num_options > 0) {
-			 //if ( x->created == 0 )  pmenu_w_menu(x, glist, CREATE);
-			 if ( x->current_selection != -1 ) {
-				 sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] %i\n",x,x->current_selection);
-			 } else {
-				sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] \n",x);
-		   	}
-		 }
-		return (1);
-}
-*/
 
-/*
-t_widgetbehavior   pmenu_widgetbehavior = {
-  w_getrectfn:  pmenu_w_getrect,
-  w_displacefn: pmenu_w_displace,
-  w_selectfn:   pmenu_w_select,
-  w_activatefn: NULL,
-  w_deletefn:   pmenu_w_delete,
-  w_visfn:      pmenu_w_vis,
-  //w_clickfn:    NULL,
-  w_clickfn:    (t_clickfn)pmenu_w_click,
-}; 
-*/
+
-- 
cgit v1.2.1