[PD] reusable snippets with key commands WAS: left mouse click abuse

Mathieu Bouchard matju at artengine.ca
Tue Jan 6 20:19:30 CET 2009


On Tue, 6 Jan 2009, Patrice Colet wrote:

> how do you get a specific selected object with using [objectcount]?

You don't, you have to make a new class very similar to [objectcount], 
that's all.

#include <m_pd.h>
#include "g_canvas.h"
typedef struct {t_object o; t_canvas *c;} t_objectselect;
static t_class *objectselect_class;
t_pd *objectselect_new (void) {
   t_objectselect *self = (t_objectselect *)pd_new(objectselect_class);
   self->c=canvas_getcurrent();
   return (t_pd *)self;
}
void objectselect_float(t_objectselect *self, t_float f) {
   glist_noselect(self->c);
   int i=0; t_gobj *o = self->c->gl_list;
   for (; o; i++, o=o->g_next) if (i==(int)f) break;
   if (o) glist_select(self->c,o);
}
void objectselect_setup (void) {
   objectselect_class=class_new(gensym("objectselect"),
     (t_newmethod)objectselect_new,0,sizeof(t_objectselect),0,0);
   class_addfloat(objectselect_class,objectselect_float);
}

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec


More information about the Pd-list mailing list