Re: dsp-gui object getting notified on patcher modifications

Forums > Dev > dsp-gui object getting notified on patcher modifications
February 19, 2011 | 6:58 pm

Hi there,

this is fairly simple but not as simple as it seems.

1 – Generally the patcherview is not immediately available to you when the object is created because a patcher is being read from disk. So you cannot attach to the patcherview in the new_method without using proper deferring functions.

2 – In UI objects (and ONLY in UI objects) our life is made a little bit easier by the existence of two optional methods:


So add these two methods to your class like this:

class_addmethod(c, (method)yourobj_patcherview_vis, "patcherview_vis", A_CANT, 0);
class_addmethod(c, (method)yourobj_patcherview_invis, "patcherview_invis", A_CANT, 0);

3 – attach to the patcherview in patcherview_vis() and detach in patcherview_invis():

void yourobj_patcherview_vis(t_yourobj *x, t_object *patcherview)
    object_attach_byptr(x, x->arrangeView);

void yourobj_patcherview_invis(t_yourobj *x, t_object *patcherview)
    object_detach_byptr(x, x->arrangeView);
    x->arrangeView = NULL;

Notice that because the current patcherview is passed as an argument to the two methods, you might not need to keep a pointer in your data structure, but that’s really up to your needs…

Let me know if you manage to get it working…


– Luigi

Subscribe to the Cycling '74 Weekly Newsletter

Let us tell you about notable Max projects, obscure facts, and creative media artists of all kinds.

* indicates required