diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index d2c3217dc5452f92b551e045f13f1188216e4213..b77230834c6205dbd2353681319acfa3d70abf56 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -707,7 +707,7 @@ int glist_selectionindex(t_glist *x, t_gobj *y, int selected) return (indx); } -static t_gobj *glist_nth(t_glist *x, int n) +t_gobj *glist_nth(t_glist *x, int n) { t_gobj *y; int indx; diff --git a/pd/src/g_text.c b/pd/src/g_text.c index 9d12259b5a03964647bf030d356c07fe14ff40c6..bfaf69551283c049135508ac94565e2ce1d00817 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -253,6 +253,8 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, } extern int sys_noautopatch; +extern t_gobj *glist_nth(t_glist *x, int n); +extern int glist_getindex(t_glist *x, t_gobj *y); /* utility routine to figure out where to put a new text box from menu and whether to connect to it automatically */ void canvas_howputnew(t_canvas *x, int *connectp, int *xpixp, int *ypixp, @@ -275,14 +277,24 @@ void canvas_howputnew(t_canvas *x, int *connectp, int *xpixp, int *ypixp, if (connectme) { t_gobj *g, *selected = x->gl_editor->e_selection->sel_what; - for (g = x->gl_list, nobj = 0; g; g = g->g_next, nobj++) - if (g == selected) + t_text *t = (t_text *)selected; + int recreate = 0; + // if selected object has not yet been activated we need to recreate it first + if (pd_class(&t->te_pd) == text_class && t->te_type != T_TEXT) { - gobj_getrect(g, x, &x1, &y1, &x2, &y2); - indx = nobj; - *xpixp = x1; - *ypixp = y2 + 5; + glist_noselect(x); // we do this to explicitly activate object + glist_select(x, glist_nth(x, glist_getindex(x, 0)-1)); // then reselect it + selected = x->gl_editor->e_selection->sel_what; + recreate = 1; } + for (g = x->gl_list, nobj = 0; g; g = g->g_next, nobj++) + if (g == selected) + { + gobj_getrect(g, x, &x1, &y1, &x2, &y2); + indx = nobj; + *xpixp = x1; + *ypixp = y2 + 5; + } glist_noselect(x); /* search back for 'selected' and if it isn't on the list, plan just to connect from the last item on the list. */ @@ -1511,7 +1523,7 @@ static void text_select(t_gobj *z, t_glist *glist, int state) rtext_select(y, state); //fprintf(stderr,"text_select %s %d\n", rtext_gettag(y), state); - // text_class is either a comment or an object that failed to creates + // text_class is either a comment or an object that failed to create // so we distinguish between it and comment using T_TEXT type check if (pd_class(&x->te_pd) == text_class && x->te_type != T_TEXT) outline = "$pd_colors(dash_outline)";