From f96782274dcbd5fb6dce9311ea103aa18747703e Mon Sep 17 00:00:00 2001 From: Guillem <guillembartrina@gmail.com> Date: Thu, 2 Jul 2020 13:11:14 +0200 Subject: [PATCH] fix text object textarea width when activating --- pd/nw/pdgui.js | 7 +++---- pd/src/g_rtext.c | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 206eef9aa..38dbe1b09 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -5822,11 +5822,10 @@ function gui_textarea(cid, tag, type, x, y, width_spec, height_spec, text, p.style.setProperty("transform", "translate(0px, " + (zoom > 0 ? 0.5 : 0) + "px)"); p.style.setProperty("max-width", - width_spec !== 0 ? width_spec + "ch" : "60ch"); + width_spec > 0 ? width_spec + "ch" : "60ch"); p.style.setProperty("min-width", - width_spec <= 0 ? "3ch" : - (is_gop == 1 ? (width_spec - 5) + "px" : - width_spec + "ch")); + is_gop == 1 ? (width_spec - 5) + "px" : + (width_spec < 0 ? (-width_spec) + "px" : width_spec + "ch")); // set backgroundimage for message box if (type === "msg") { diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c index b82f34701..c4187861b 100644 --- a/pd/src/g_rtext.c +++ b/pd/src/g_rtext.c @@ -607,7 +607,9 @@ void rtext_activate(t_rtext *x, int state) } else { - widthspec = x->x_text->te_width; // width if any specified + int xmin, xmax, tmp; + gobj_getrect(&x->x_text->te_g, x->x_glist, &xmin, &tmp, &xmax, &tmp); + widthspec = (x->x_text->te_width ? x->x_text->te_width : -(xmax-xmin)); // width if any specified heightspec = -1; // signal that we don't have a heightspec isgop = 0; } -- GitLab