Max5 UI objects

Roby Steinmetzer's icon

On 17 nov. 08, at 17:32, Emmanuel Jourdan wrote:
>> On 17 nov. 08, at 16:01, Roby Steinmetzer wrote:
>>> 2. Where do I get my object's information like position, size
>>> etc. in the case of opening a Max4 patcher?

> You need to add a stdargs methods in your main:
>
>     class_addmethod(c, (method)yourobj_stdargs, "stdargs", A_CANT, 0);
>
> This method will be called when you do a attr_dictionary_process()
> in your yourobj_new() method. In your stdargs method you can mess
> with the dictionary:
>
> t_max_err your_stdargs(t_dictionary *d, t_symbol *s, long argc,
> t_atom *argv)
> {
>     // if your object had something like for values to define x y width
> height
>     if (d && argc>3) {
>         dictionary_appendatoms(d, gensym("patching_rect"), 4, argv);
>     }
>     return MAX_ERR_NONE;
> }
>
> ej

Thanks Emmanuel,
this works great.

how about my other question:
> 1. How do I make appear my UI object in the objects palette?
> Putting an myobject.svg in the objects-palette folder doesn't seem
> to be enough.

Roby

Emmanuel Jourdan's icon

On 18 nov. 08, at 00:50, Roby Steinmetzer wrote:

> how about my other question:
>>
>> 1. How do I make appear my UI object in the objects palette?
>> Putting an myobject.svg in the objects-palette folder doesn't seem
>> to be enough.

I'll let David answer to that one in details, but basically you need
to put some svg file in the object-palette folder as well as messing
around with some palette*.json file.

ej

Hugobox's icon

In the object-palette folder, edit the palette*.json files with a text editor. you can then insert something like:
{
"box" : {
    "maxclass" : "fpic",
    "numinlets" : 1,
    "numoutlets" : 0,
    "patching_rect" : [ 360.0, 378.0, 48.0, 48.0 ],
    "pic" : "svgfilename.svg",
    "autofit" : 1,
    "id" : "obj-14",
    "instance_attributes":     {
        "palette_numerical_order" : 14,
        "palette_category" : "Interface",
        "palette_caption" : "displayedname",
        "palette_action" : "bpatcher @name maxpatfilename"
    }
}

But the "palette category" seems broken for me, at one point it was working fine: I could create my own categories (tabs), but now even regular objects are missing from certain categories. Anyone else has this problem?

Hugobox's icon

ok so yeah you need to edit the palette*.json file with a text editor and not directly with max, otherwise you'll end up with semi-functional palettes.