attribute turns "none" how to?
sorry if i just did not find it in the docs.
how can i define a (type double) attribute, that turns when the user deletes the value in the inspector?
same behaviour like in the number inspector at minimum and maximum.
i thought it would be a style of CLASS_ATTR_STYLE but obviously it is not..
thanks
klaus
There's no style for that. You need to set the attribute type to ATOM, and roll your own gettr/settr methods. That's what we do for number e.g.
ok,
thanks for the quick answer.
is there any chance to have a look into number.c ?
klaus
It probably looks like something like this:
CLASS_ATTR_ATOM(c, "myattr", 0, t_myobject, myattr);
CLASS_ATTR_ACCESSORS(c, "myattr", (method)NULL, (method)myobject_setattr_myattr);
t_max_err myobjet_setattr_myattr(t_myobject *x, void *attr, long ac, t_atom *av)
{
if (ac && av) {
if (atom_gettype(av) == A_LONG || atom_gettype(av) == A_FLOAT) {
x->myattr = *av;
else
atom_setsym(&x->myattr, gensym(""));
} else
atom_setsym(&x->myattr, gensym(""));
return MAX_ERR_NONE;
}
forum coding.
emmanuel, thanks again!
works like a charm
(there is a typo at:
"t_max_err myobjet_ser..." better is:
"t_max_err myobjet_set...
Glad it works, typo fixed.