Function copy/paste

John MacCallum's icon

Hi,

I noticed that when you copy and paste an object like the function object, the contents of the old object appear in the new one. I was wondering if someone could tell me how to make a custom gui object behave that way--it's a really nice behavior.

Thanks in advance,
JM

Emmanuel Jourdan's icon

Hey John,

your object needs to implement a jsave method.

class_addmethod(c, (method)yourobject_jsave, "jsave", A_CANT, 0);

The method will receive the object dictionary as argument, so you just need to add whatever you want to it:

void yourobject_jsave(t_yourobject *x, t_dictionary *d)
{
dictionary_appendlong(d, gensym("hey"), 74);
//...
}

This means that the object should implements the hey message, and it will be called when the object is instantiated.

forum coding...
Cheers,
ej