Object with editing windows (2nd attempt)

May 5, 2011 at 1:00pm

Object with editing windows (2nd attempt)

Hi there,

I did a quick search in the archives and I found a few threads asking the same information, but all with no answer.

I have an object that displays an editing window, pretty much like coll.
When coll’s editing window is open all items in the View menu are dimmed out.

I would like to achieve the same behavior, but unfortunately when my window is open the New View, Presentation, Zoom In and Zoom Out items are still editable.

How to dim those out as well. ?

The relevant code snippet is:

atom_setobj(&atom, dict);
x->patcher = object_new_typed(CLASS_NOBOX, _sym_jpatcher, 1, &atom);
if (x->patcher) {
     object_attr_setchar(x->patcher, gensym("locked"), 1);     // Lock patcher
     object_attr_setchar(x->patcher, gensym("noedit"), 1);     // Disable Edit item from View menu

    // now I would need other messages to send the patcher object
    // to disable the New View, Navigation, Zoom In, Zoom Out items
}

Thanks for any help.

- Luigi

#56873
May 5, 2011 at 4:01pm

Hi Luigi.

Here (Max 5.1.8, OSX 10.6.7), simpletext and coll behave exactly the same way with respect to the patcher buttons – they’re grayed out when the patcher window is in background, and get editable again when the patcher goes to foreground…

aa

#203880
May 5, 2011 at 4:37pm

Sorry Andrea,

I don’t understand your reply…
Maybe I haven’t been too clear with my question.

I am creating an object with an editing window. You open the editing window by double-clicking on the object. It’s the same behavior implemented in the coll object. You probably know already that to create an editing window, you basically create a new patcher window. Coll does that but with the exception that – in order to avoid any type of user editing operation – the new patcher window has some attributes set that make it uneditable. When I say uneditable I mean that the usual operations that you can perform in a patcher such as creating a new object, create a new view, zooming in or out, etc.. all those operation are unavailable in this patcher window. You can only type text in it. In the case of coll that’s achieved with the help of a textfield, but in my case I don’t even need that. I just want to make my patcher window uneditable. I would like to know the messages I need to send to the patcher or attributes I need to set in order to achieve that.

More specifically, the items I want to gray out are in the View menu and are:
New View, Navigation, Zoom In, Zoom Out.

Those items are always grayed out in the coll editing window, no matter if the window is in the background or foreground. But in my window they are not grayed out, so the user could potentially zoom in, zoom out, create a new view, etc… I don’t want to give that option to the user.

Hope this clarifies my question but if it doesn’t please don’t hesitate to let me know.

Thanks.

- Luigi

#203881
May 5, 2011 at 6:27pm

Hi Luigi.

Now I see what you mean, actually it was quite clear from your code. My bad, I looked at it too hastily – I was assuming you were talking about a text editor window (which is what coll displays), not a patcher window.

In this case I can’t really help you. The only suggestion I can give you is to try looking inside the c_messlist and c_attributes fields of the t_class of jpatcher… I have found some interesting things this way!

best
aa

#203882
May 5, 2011 at 6:40pm

Don’t worry, no problem at all.

Yes, your suggestion is what I have done already and – even if sometimes it works – this time around I couldn’t find anything.

In any case, thanks anyway…

- Luigi

#203883
May 10, 2011 at 9:15pm

Hi Luigi,

Here is a small snippet from the File Browser:

sprintf(parsebuf,"@defrect %.6f %.6f %.6f %.6f @title "File Browser" @bgcolor %.6f %.6f %.6f %.6f @presentation 0 @toolbarid browserwindow",
			x->windowrect.x, x->windowrect.y, s_browserwindow_rect.width, s_browserwindow_rect.height,
			bg.red, bg.green, bg.blue, bg.alpha);
	atom_setparse(&ac, &av, parsebuf);
	attr_args_dictionary(d, ac, av);

The key here is that the @toolbarid attribute is set to something other than patcher. Max’s menus will then no longer treat your patcher as a patcher.

We haven’t documented any of this material about creating custom editor windows like this, and we’re quite busy at the moment, so you are mostly going to be on your own for this custom-editor endeavor. Hopefully this small snippet will help though!

best wishes,
Tim

#203884
May 18, 2011 at 5:05pm

Hi Tim,

thank you, but I can’t produce the behavior you described.
I tried several times with pretty much the same code making sure I would change the @toolbarid attribute.

What the @toolbarid attribute does is to change the small action icons at the bottom of various windows according to the “toolbars” category described in the maxinterface.json file, but the Max menu does not gray out any items.

Here is the relevant code I have:

t_dictionary *dict;

dict = dictionary_new();
if (dict) {

    char parsebuf[512];
    long argc = 0;
    t_atom *argv = NULL;

    sprintf(parsebuf, "@defrect %f %f %f %f @title "My Window" @bgcolor 0.0 0.0 0.0 1.0 @presentation 0 @toolbarid browserwindow",
                 x->rect.x, x->rect.y, x->rect.width, x->rect.height);
    atom_setparse(&argc, &argv, parsebuf);
    if (argc && argv) {

        t_atom a;

        attr_args_dictionary(dict, argc, argv);
        sysmem_freeptr(argv);

        atom_setobj(&a, dict);
        x->patcher = object_new_typed(CLASS_NOBOX, _sym_jpatcher, 1, &a);

        // etc....
    }
    object_free(dict);
}

Sorry to keep bothering, I feel I am very close…
Is there something else I need to change or add maybe ?

Thanks a lot.

- Luigi

#203885

You must be logged in to reply to this topic.