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

Patrice Colet pat at mamalala.org
Tue Jan 6 23:34:51 CET 2009


  In fact both object classes are interdependent, [objectcount] get 
object number at loadbang, and we can have a range for [objectselect]


Mathieu Bouchard a écrit :
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: objecttools.zip
Type: application/octet-stream
Size: 6584 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20090106/f7539db9/attachment.obj>


More information about the Pd-list mailing list