From c33aace2518b908ce3f924d03334247fa2b65915 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Wed, 23 Sep 2020 14:04:34 -0400 Subject: [PATCH] Enabled visual feedback when clicking on the empty symbol gatom to edit its value * Before empty symbol gatom had no feedback when being clicked on and one had to start typing trusting that the object is indeed properly activated. * Now, the object draws ... as soon as an empty (and only empty) symbol gatom is selected, so that it has text to highlight thereby letting the user know that the object is ready to receive their input. In case the symbol gatom already has content, then that content gets highlighted which serves the same purpose. * This does not affect the float gatom. --- pd/src/g_text.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pd/src/g_text.c b/pd/src/g_text.c index b7363b4c3..65c6d99bf 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -1112,7 +1112,7 @@ static void gatom_key(void *z, t_floatarg f) { t_gatom *x = (t_gatom *)z; int c = f; - //post("gatom_key <%c> %d", c, x->a_shift); + //post("gatom_key %f %d", f, x->a_shift); int len = strlen(x->a_buf); t_atom at; char sbuf[ATOMBUFSIZE + 4]; @@ -1139,7 +1139,11 @@ static void gatom_key(void *z, t_floatarg f) else if (x->a_atom.a_type == A_SYMBOL) { //post("gatom_key release"); - if (strcmp(x->a_buf, x->a_atom.a_w.w_symbol->s_name)) + // ico@vt.edu 20200923: we also check for empty a_buf to ensure that + // the ... is deleted. This was created when the object was originally + // clicked on below, but only if the current gatom is symbol type and + // is empty. + if (x->a_buf[0] == 0 || strcmp(x->a_buf, x->a_atom.a_w.w_symbol->s_name)) { strcpy(x->a_buf, x->a_atom.a_w.w_symbol->s_name); gatom_retext(x, 1, 1); @@ -1256,6 +1260,16 @@ static void gatom_click(t_gatom *x, return; } x->a_shift = shift; + if (x->a_atom.a_type == A_SYMBOL && !strlen(x->a_atom.a_w.w_symbol->s_name)) + { + char sbuf[ATOMBUFSIZE + 4]; + t_atom at; + sprintf(sbuf, "%s...", x->a_buf); + SETSYMBOL(&at, gensym(sbuf)); + binbuf_clear(x->a_text.te_binbuf); + binbuf_add(x->a_text.te_binbuf, 1, &at); + glist_retext(x->a_glist, &x->a_text); + } glist_grab(x->a_glist, &x->a_text.te_g, gatom_motion, gatom_key, xpos, ypos); //post("a_shift_clicked=%d", x->a_shift_clicked); -- GitLab