attribute turns "none" how to?

    Dec 28 2010 | 3:39 pm
    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

    • Dec 28 2010 | 5:05 pm
      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.
    • Dec 28 2010 | 7:33 pm
      ok, thanks for the quick answer.
      is there any chance to have a look into number.c ?
    • Dec 28 2010 | 9:14 pm
      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;
                  atom_setsym(&x->myattr, gensym(""));
          } else
              atom_setsym(&x->myattr, gensym(""));
           return MAX_ERR_NONE;
      forum coding.
    • Dec 28 2010 | 11:23 pm
      emmanuel, thanks again! works like a charm
      (there is a typo at: "t_max_err myobjet_ser..." better is: "t_max_err myobjet_set...
    • Dec 29 2010 | 10:09 am
      Glad it works, typo fixed.